[R] Random Sequence
Francisco J. Zagmutt
gerifalte28 at hotmail.com
Thu Apr 12 23:36:39 CEST 2007
There are many ways to do this.
The first that comes to my mind is sample(c(1,-1),100,TRUE). Notice
that sample also has a prob argument that may be useful for you.
Anup Nandialath wrote:
> Dear Friends,
> I'm trying to generate a sequence of 100 observations
> with either a 1 or -1. In other words the sequence
> should look something like this.
> y = 1 1 -1 1 -1 -1 -1 1 1 ......
> Can somebody please give me some direction on how I
> can do this in R.
> Don't get soaked. Take a quick peak at the forecast
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help