Dear all, good morning, I have a population, let say members are tagged with some simple number like 1,2,3,...20. I want to draw a sample with replacement of size 4 (say, can be more than 20 also). Is there any R function which will show me all such possible samples? Thanks [[alternative HTML version deleted]]
sample(1:20,4,replace=TRUE) should do it. Jun On Wed, Jun 16, 2010 at 9:20 AM, Somnath Somnath <somnath700004@gmail.com>wrote:> Dear all, good morning, > > I have a population, let say members are tagged with some simple number > like > 1,2,3,...20. I want to draw a sample with replacement of size 4 (say, can > be > more than 20 also). Is there any R function which will show me all such > possible samples? > > Thanks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Try sample(20, 4, replace = TRUE) HTH, Jorge On Wed, Jun 16, 2010 at 10:20 AM, Somnath Somnath <> wrote:> Dear all, good morning, > > I have a population, let say members are tagged with some simple number > like > 1,2,3,...20. I want to draw a sample with replacement of size 4 (say, can > be > more than 20 also). Is there any R function which will show me all such > possible samples? > > Thanks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On Jun 16, 2010, at 10:20 AM, Somnath Somnath wrote:> Dear all, good morning, > > I have a population, let say members are tagged with some simple > number like > 1,2,3,...20. I want to draw a sample with replacement of size 4 > (say, can be > more than 20 also).Already answered on the list.> Is there any R function which will show me all such > possible samples??expand.grid > nrow(expand.grid(1:20, 1:20, 1:20, 1:20)) [1] 160000 -- David Winsemius, MD West Hartford, CT
How about library(TeachingSampling) SupportWR(20,4) Tom -- View this message in context: r.789695.n4.nabble.com/Sampling-with-replacement-tp2257450p2257644.html Sent from the R help mailing list archive at Nabble.com.