In a date frame I have two different columns inno01$Q9A.1 and inno01$Q9B.1 and I want to create a new variable (call it inno01$Q9R.1) that takes the values of inno01$Q9A.1 if the value is available and the values of inno01$Q9B.1 in any other case.
I have written
inno01$Q9R.1 = ifelse(inno01$Q9A.1 == "NA", as.factor(inno01$Q9B.1),as.factor( inno01$Q9A.1))
It doesn't work . Can anyone help me?
Aucun commentaire:
Enregistrer un commentaire