Hi Judith, Also you can try
NSIM=20 # Number of samples res=apply(matrix(rep(rep(LETTERS[1:2],12),NSIM),ncol=NSIM),2,sample) res I hope this helps. Jorge Iván Vélez On 2/5/08, Daniel Dunn <[EMAIL PROTECTED]> wrote: > > sample(rep(LETTERS[1:2],12), 24, replace=F) > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On > Behalf Of Judith Flores > Sent: Tuesday, February 05, 2008 1:52 PM > To: RHelp > Subject: [R] Sampling > > Hi there, > > I want to generate different samples using the followindg code: > > > g<-sample(LETTERS[1:2], 24, replace=T) > > How can I specify that I need 12 "A"s and 12 "B"s? > > Thank you, > > Judith > > > > > ____________________________________________________________________________ > ________ > Be a better friend, newshound, and > > ______________________________________________ > R-help@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]]
______________________________________________ R-help@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.