-----Original Message-----
From: lynn.tsai
Sent: Wednesday, January 04, 2012 3:38 PM
To: r-help@r-project.org
Subject: [R] a quick question about "rbinom"
Hello, I have the following code using rbinom, but I don't understand what
*"+1"* means in the code. Could someone help? Thanks so much,
X1<-c("A","B")[rbinom(n,1,0.6)+1]
X2<-c("C","D")[rbinom(n,1,0.1)+1]
It mean index the vector as 1's and 2's (1st and 2nd item in list) rather
than 0's and 1's because R indices start at 1, not 0.
------------------------------------------
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
FAX 660-626-2965
______________________________________________
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.