> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Keller
> Sent: Thursday, April 12, 2007 2:32 PM
> To: Anup Nandialath
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] Random Sequence
> 
> Hi Anup,
> 
> (runif(100)<.5)*1   #would give you 0's and 1's.
> 
> sample(rep(c(-1,1),50),100)  #A bit slower I think, gives you 
> -1's and 1's
> 

How about

  sample(c(-1,1), 100, replace=TRUE) 

Hope this is helpful,

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204

______________________________________________
[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.

Reply via email to