[R] random sampling with levels and with replacement

From: taby gathoni <tabieg_at_yahoo.com>
Date: Fri, 08 Apr 2011 00:31:44 -0700 (PDT)


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 that my random samples generated dont maintain the ratio. My code is as  :

mysample <- final[sample(1:nrow(final), 400,replace=TRUE),]

does not give me the ratio of 40 bad and 360 good can anyone give me some pointers please?

Thanks,
Taby

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 08 Apr 2011 - 07:34:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Apr 2011 - 09:20:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive