I have a two binomial variables and I need to create a new variable (var3) such that
if var1=0 and var2=0 then var3=0
if var1=1 and var2=1 then var3=1
if var1=1 and var2=0 then var3=1
if var1=0 and var2=1 then var3=1
Let var1=c(1,0,1,0,1,1)
var2=c(0,0,1,1,0,1)
I know I can use as.integer(Var1|Var2|Var3) and pmax(Var1, Var2), but how to do it using loops in R.
Aucun commentaire:
Enregistrer un commentaire