[R] Random number generator in R compared

Daniel Nordlund res90sx5 at verizon.net
Fri Apr 20 09:40:02 CEST 2007


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch]
> On Behalf Of raymond chiruka
> Sent: Thursday, April 19, 2007 5:23 AM
> To: R-help at stat.math.ethz.ch
> Subject: Re: [R] Random number generator in R compared
> 
> I am trying to generate survival data using R .Im trying to randomly  generate a
> column of 1s and 0 and another column randomly  generated using an exponential
> distribution but l cant seem to get the  random function. how do l go about it
> 
>   thanks in advance
> 
>   rt chiruka
> 

To get your random column of 0's and 1's try
 ?sample.

  y <- sample(c(0,1), size=100, replace=TRUE)

For your random sample from an exponential distribution try
?rexp

 x <- rexp(100)

Hope this is helpful,

Dan

Dan Nordlund
Bothell, WA



More information about the R-help mailing list