sample(1:2, 10, replace=TRUE) > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of raymond chiruka > Sent: Wednesday, April 25, 2007 9:45 AM > To: [email protected] > Subject: [R] creating random numbers > > l want to create a column of 1 and 2 randomly what > command should l use > eg > treatment strata > > 1 1 > 2 0 > 1 1 > 2 1 > 2 0 > 2 1 > 2 0 > 1 0 > these should be created randomly > > secondly if l have something like > for (i in 1:n ) df =c(1,rexp(1,.001),rexp(1,.002)) can l > add an if statement in side the c maybe to compare the 2 > exponential numbers to create another variable > > > --------------------------------- > > > [[alternative HTML version deleted]] > > ______________________________________________ > [email protected] 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. >
______________________________________________ [email protected] 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.
