Hi R users,
This question is similar to the previous one.
I am providing this example data to get my question across.
id=c(1,2,3,4,5,6,7,8,9,10)
var1=c(0,1,2,0,6,9,0,0,3,0)
var2=c(0,0,2,3,0,0,0,5,0,0)
var3=c(0,1,4,3,6,9,0,5,3,0)
data=data.frame(id,var1,var2, var3)
What I need is:
if values of var1==var2
, then make var3==NA
but if they are not then keep the value of var3
.
Would be glad to get it done using the ifelse
function in R but other options are welcomed.
I hope that the question is clear enough.
Regards, Bazon