I have a small problem, or acctually kind of large. I have a dataset with 3 variables that I use atm, lets call them var1, var2 and var3. In total I have over 3000 observations with NA values in every variable.
var1=age_1, var2=Yes/No and var3=age_2
What I want to do is if var2="Yes" the value from var1 should be coopied into var3. I have done it in this way:
var3[var2=="Yes"]<-var1
but I get the error message:
Error in var3[var2 == "Yes"] <-var1 :
NAs are not allowed in subscripted assignments
Someone has a quick solution how I can solve this?