[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

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 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 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

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 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