[R] Correlated variables
Art U
art.tem.us at gmail.com
Wed Mar 15 15:56:14 CET 2017
Hi,
I'm trying to create binary variable which distribution conditioned on
other variables. That is what I did,
x1=rnorm(n,0,1);
x2=rnorm(n,0,1);
x3=rnorm(n,0,1);
if(x1+x2-x3>0.25){
t=rbinom(1, 1, prob=0.25)
}else{
t=rbinom(1, 1, prob=0.5)
}
But I always get this the warning:
Warning message:In if (x1 + x2 - x3 > 0.5) { :
the condition has length > 1 and only the first element will be used
Can I do this without using function "for"?
Thank you in advance.
Ariel
--
*I like to pretend I'm alone*. *Completely alone*. *Maybe post-apocalypse
or plague*... *Whatever*. *No-one left to act normal for. No need to hide
who I really am. It would be... freeing*. *...*
[[alternative HTML version deleted]]
More information about the R-help
mailing list