Re: [R] random sampling with levels and with replacement

2011-04-10 Thread taby gathoni
Andreas, Thanks alot. I  combined below and other suggestions given on r-help and it worked. --- On Fri, 4/8/11, Andreas Borg wrote: From: Andreas Borg Subject: Re: [R] random sampling with levels and with replacement To: tab...@yahoo.com Cc: "R help" Date: Friday, Apr

Re: [R] random sampling with levels and with replacement

2011-04-08 Thread taby gathoni
Thanks Daniel, Its a long way but it will work. --- On Fri, 4/8/11, Daniel Malter wrote: From: Daniel Malter Subject: Re: [R] random sampling with levels and with replacement To: r-help@r-project.org Date: Friday, April 8, 2011, 10:08 AM If you want perfect equality, split the data

Re: [R] random sampling with levels and with replacement

2011-04-08 Thread Andreas Borg
Hi, I am not perfectly sure what you want to do, but here is what I would do to maintain good/bad ratio in the sample (as Daniel posted, split the data and sample from the groups): df <- data.frame(V1 = 1:400, V2 = c(rep("good",360), rep("bad",40))) isGood <- which(df$V2=="good") isBad <- whi

Re: [R] random sampling with levels and with replacement

2011-04-08 Thread Daniel Malter
If you want perfect equality, split the data in good and bad and sample from the two samples individually. On average, however, random sampling from the entire data will reproduce the proportion of good and bad in the data. hth, Daniel -- View this message in context: http://r.789695.n4.nabbl

[R] random sampling with levels and with replacement

2011-04-08 Thread taby gathoni
Dear all, i have a dataset of about 400 records , with a variable that has  two levels 40 bad and 360 good among other variables,how do i come up  with10 random samples that have the composition of as the main sample  but maintaining the 40 bad 360 good with replacement, i recently discovered th