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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.