On 20/11/2008, at 11:47 AM, [EMAIL PROTECTED] wrote:

Dear R people,
what functions generate respectively vectors with each element is respectively zero and one.
sorry for my credulous questions and many thanks in advance.

If you want a *random* (i.i.d.) vector of zeroes and ones, then the following sort of thing
will do it:

        sample(0:1,42,TRUE) # TRUE is necessary for sampling with replacement.
sample(0:1,42,TRUE,prob=c(0.25,0.75)) # 1/4 zeroes and 3/4 ones on average; the default is equal probabilities.

If you want some non-random structure, or if you want serial dependence between the entries
you need to make your question more explicit.

*Do* read the posting guide!

        cheers,

                Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

Reply via email to