Re: [R] random sample set for regression

2018-01-25 Thread Rui Barradas
Hello, Can you please post the output of dput(all) # if all is small dput(head(all, 30)) # if all is big in a mail? Hope this helps, Rui Barradas On 1/24/2018 4:28 PM, Francisca R. Souza Pereira wrote: Hi, I'm not a programmer, so I have a question about R functions, I run the Random Fo

[R] random sample set for regression

2018-01-24 Thread Francisca R. Souza Pereira
Hi, I'm not a programmer, so I have a question about R functions, I run the Random Forest regression models, but I would like to run the random forest model 1000 times with different random sample set. to check the uncertainty of the regression model estimates. exemple of data: ##

Re: [R] Random Sample with constraints

2013-03-03 Thread Ted Harding
On 03-Mar-2013 16:29:05 Angelo Scozzarella Tiscali wrote: > For example, I want to simulate different populations with same mean and > standard deviation but different distribution. > > Il giorno 03/mar/2013, alle ore 17:14, Angelo Scozzarella Tiscali ha scritto: >> Dear R friends, >> >> I'd lik

Re: [R] Random Sample with constraints

2013-03-03 Thread Angelo Scozzarella Tiscali
For example, I want to simulate different populations with same mean and standard deviation but different distribution. Il giorno 03/mar/2013, alle ore 17:14, Angelo Scozzarella Tiscali ha scritto: > Dear R friends, > > I'd like to generate random sample (variable size and range) without a >

Re: [R] Random Sample with constraints

2013-03-03 Thread Ben Bolker
Angelo Scozzarella Tiscali tiscali.it> writes: > > Dear R friends, > > I'd like to generate random sample (variable size and range) without a specified distribution but with > given mean and standard deviation. > > Could you help me? > The problem is underspecified, so no, we can't. A

[R] Random Sample with constraints

2013-03-03 Thread Angelo Scozzarella Tiscali
Dear R friends, I'd like to generate random sample (variable size and range) without a specified distribution but with given mean and standard deviation. Could you help me? thanks in advance Angelo __ R-help@r-project.org mailing list https://stat.e

Re: [R] random sample from list

2012-04-05 Thread David Winsemius
On Apr 5, 2012, at 12:00 AM, Daisy Englert Duursma wrote: random selection of cells in raster based on distance from xy locations Hi, I am trying to sample a raster for random cells that occur within a specific distance of point locations. I have successfully found multiple ways of doing

Re: [R] random sample from list

2012-04-05 Thread Rui Barradas
Hello, > > #Here is how I have tried to sample but it is not sampling from the right > part of the list > > bg<- z_nonna[sample(1:length(z_nonna), 5000, replace=FALSE)] > You are sampling from the length of z_nonna, with no guarantee that they are indices to unique list elements. Try this. #

[R] random sample from list

2012-04-04 Thread Daisy Englert Duursma
random selection of cells in raster based on distance from xy locations Hi, I am trying to sample a raster for random cells that occur within a specific distance of point locations. I have successfully found multiple ways of doing this but have memory issues with very large datasets. To overcome

Re: [R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame

2012-03-30 Thread inkhorn
Okay thanks to your help I figured it out and stuck the code in a function: df.sample.exIDs = function(main.df, sample1.df, n, ID1.name, ID2.name) { main.ID1.notin.ID2 = main.df[!main.df[,ID1.name] %in% sample1.df[,ID2.name],] sample2.df = main.ID1.notin.ID2[sample(nrow(main.ID1.notin.ID2), si

Re: [R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame

2012-03-30 Thread David Winsemius
On Mar 30, 2012, at 8:17 AM, inkhorn wrote: Okay, here's some sample code: ID = c(1,2,3,"A1",5,6,"A2",8,9,"A3") fakedata = rnorm(10, 5, .5) main.df = data.frame(ID,fakedata) results for my data frame: main.df ID fakedata 1 1 5.024332 2 2 4.752943 3 3 5.408618 4 A1

Re: [R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame

2012-03-30 Thread inkhorn
Okay, here's some sample code: ID = c(1,2,3,"A1",5,6,"A2",8,9,"A3") fakedata = rnorm(10, 5, .5) main.df = data.frame(ID,fakedata) results for my data frame: > main.df ID fakedata 1 1 5.024332 2 2 4.752943 3 3 5.408618 4 A1 5.362838 5 55.158660 6 64.658235 7

Re: [R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame

2012-03-29 Thread David Winsemius
On Mar 29, 2012, at 4:22 PM, inkhorn wrote: When I use that exact syntax Which you didn't include as context. Please read the Posting Guide. (with the ID variable names You are the one the offered "ID" as the column name. in quotes within the square brackets after a comma) it just doesn

Re: [R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame

2012-03-29 Thread inkhorn
When I use that exact syntax (with the ID variable names in quotes within the square brackets after a comma) it just doesn't work. Also, I'm looking for a random sample, not all possible rows with ID values that don't match the second data frame. -- View this message in context: http://r.789695.

Re: [R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame

2012-03-29 Thread David Winsemius
On Mar 29, 2012, at 2:37 PM, inkhorn wrote: Hello, Let's say I've drawn a random sample () from a large data frame (main.df), and I want to create a second random sample (sample2.df) where the values in its ID column *are not* in the equivalent ID column in the first sample (sample1.df).

[R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame

2012-03-29 Thread inkhorn
Hello, Let's say I've drawn a random sample (sample1.df) from a large data frame (main.df), and I want to create a second random sample (sample2.df) where the values in its ID column *are not* in the equivalent ID column in the first sample (sample1.df). How would I go about doing this? In other

Re: [R] Random sample from truncated distributions

2012-02-08 Thread Petr Savicky
On Wed, Feb 08, 2012 at 06:17:40AM -0800, n wrote: > Hi, > > How can I draw a random sample from a truncated distribution (especially > lognormal)? > > I found the functions for truncated normal but not for many other > distributions. Hi. A variable Y with a log-normal distribution may be obtain

[R] Random sample from truncated distributions

2012-02-08 Thread n
Hi, How can I draw a random sample from a truncated distribution (especially lognormal)? I found the functions for truncated normal but not for many other distributions. Thanks Nikhil -- View this message in context: http://r.789695.n4.nabble.com/Random-sample-from-truncated-distributions-tp

Re: [R] Random Sample

2010-11-08 Thread Giovanni Petris
Here is an example of what I think the original poster wanted to achieve. > rnorm(10) [1] -1.2165869 -0.4698460 -0.4209811 -1.4856052 0.3765774 -1.3822470 [7] 0.2818458 0.5500957 -1.1474455 -1.2221257 > x <- .Random.seed > runif(10) [1] 0.5610780 0.5911841 0.5868183 0.3833801 0.7397059 0.497

Re: [R] Random Sample

2010-11-08 Thread Jorge Ivan Velez
Hi Xiaoxi, Take a look at the following: > set.seed(123) > rnorm(10) [1] -0.56047565 -0.23017749 1.55870831 0.07050839 0.12928774 1.71506499 [7] 0.46091621 -1.26506123 -0.68685285 -0.44566197 > rnorm(10) [1] 1.2240818 0.3598138 0.4007715 0.1106827 -0.5558411 1.7869131 0.4978505 [8]

Re: [R] Random Sample

2010-11-08 Thread Erik Iverson
?set.seed is what you're looking for Xiaoxi Gao wrote: Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the same random numbers? For example, 10 random numbers is generated from N(0,1), then "runif(10)" is used.What if I want to get the

Re: [R] Random Sample

2010-11-08 Thread Jonathan P Daily
;s the word... imbue it." - Jubal Early, Firefly From: Xiaoxi Gao To: R Help Date: 11/08/2010 03:59 PM Subject: [R] Random Sample Sent by: r-help-boun...@r-project.org Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the

[R] Random Sample

2010-11-08 Thread Xiaoxi Gao
Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the same random numbers? For example, 10 random numbers is generated from N(0,1), then "runif(10)" is used.What if I want to get the same 10 random numbers when I run runif(10) again? Is i

Re: [R] random sample from arrays

2010-07-12 Thread Assa Yeroslaviz
Hi Joris, sorry for the late response. But I was away for a couple of days. Apparently i also did something wrong than. Now both these loops are working as they suppose to. Thanks again for all the help. Assa On Fri, Jul 9, 2010 at 17:05, Joris Meys wrote: > Could you elaborate? > > Both > >

Re: [R] random sample from arrays

2010-07-09 Thread Joris Meys
Could you elaborate? Both x <- 1:4 set <- matrix(nrow = 50, ncol = 11) for(i in c(1:11)){ set[,i] <-sample(x,50) print(c(i,"->", set), quote = FALSE) } and x <- 1:4 set <- matrix(nrow = 50, ncol = 11) for(i in c(1:50)){ set[i,] <-sample(x,11) print(c(i,"->", set)

Re: [R] random sample from arrays

2010-07-09 Thread Assa Yeroslaviz
Hi Joris, I guess i did it wrong again. but your example didn't work either. I still get the error massage. but replicate function just fine. I can even replicate the whole array lines. THX Assa On Thu, Jul 8, 2010 at 15:20, Joris Meys wrote: > Don't know what exactly you're trying to do, but

Re: [R] random sample from arrays

2010-07-08 Thread David Winsemius
On Jul 8, 2010, at 2:04 AM, Assa Yeroslaviz wrote: Hello R users, I'm trying to extract random samples from a big array I have. I have a data frame of over 40k lines and would like to produce around 50 random sample of around 200 lines each from this array. this is the matrix ID

Re: [R] random sample from arrays

2010-07-08 Thread Joris Meys
Don't know what exactly you're trying to do, but you make a matrix with 11 columns and 50 rows, then treat it as a vector. On top of that, you try to fill 50 rows/columns with 50 values. Off course that doesn't work. Did you check the warning messages when running the code? Either do : for(i in

[R] random sample from arrays

2010-07-07 Thread Assa Yeroslaviz
Hello R users, I'm trying to extract random samples from a big array I have. I have a data frame of over 40k lines and would like to produce around 50 random sample of around 200 lines each from this array. this is the matrix ID xxx_1c xxx__2c xxx__3c xxx__4c xxx__5T xxx__6T xxx__7T xx

Re: [R] Random Sample with Unique function

2009-04-28 Thread Krystyna Golabek
subset of the data.frame? Thanks Krystyna > Date: Tue, 28 Apr 2009 14:33:22 +0200 > From: lig...@statistik.tu-dortmund.de > To: kagola...@hotmail.com > CC: r-help@r-project.org > Subject: Re: [R] Random Sample with Unique function > > In order to use stratified sampling, eithe

Re: [R] Random Sample with Unique function

2009-04-28 Thread Uwe Ligges
la...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] Random Sample with Unique function In order to use stratified sampling, either try to implement it yourself or use the "sampling" package and its function strata() as in: s1 <- strata(cc, stratanames="ID", size

Re: [R] Random Sample with Unique function

2009-04-28 Thread Uwe Ligges
In order to use stratified sampling, either try to implement it yourself or use the "sampling" package and its function strata() as in: s1 <- strata(cc, stratanames="ID", size=rep(1, 20), method="srswr") then you will get 1 observation for each ID. Note that it is not important to use "with re

[R] Random Sample with Unique function

2009-04-28 Thread Krystyna Golabek
Dear R-users I have a dataset of 243 lines with replicate information for 20 different individuals (ID). I would like to randomly sample this dataset 100 times with a selection of unique IDs in each sample. First to create a random sample I have; cc<-read.table(blah.blah.blah) names(cc) [1]

Re: [R] Random Sample - data frame

2009-01-27 Thread Jorge Ivan Velez
Hi Andy, You forgot a comma at the end: people[sample(1:nrow(people), 10, replace = TRUE),] Now it should work as expected :-) HTH, Jorge On Tue, Jan 27, 2009 at 9:44 PM, Andy wrote: > I would like to create a random sample of the rows of a data frame that > is larger than the number of row

[R] Random Sample - data frame

2009-01-27 Thread Andy
I would like to create a random sample of the rows of a data frame that is larger than the number of rows in the data frame. With an individual vector, this is easy using select(variable, number, replace = TRUE). I looked on-line I found some guides to sample from a data frame using indexing, but I