I have some data like these
var1 var2 10 NA 101 NA NA 86 11 NA NA 11 NA 61
If one variable is NA then the other one is
rowSums with na.rm = TRUE will do this. (This is your suggested solution really...)
rowSums
na.rm = TRUE
Assuming your data are in a data.frame DF and your comment
data.frame
DF
If one variable is NA then the other one is not, and vice-versa.
is true.
DF$var3 <- rowSums(DF[, c('var1','var2')], na.rm = TRUE)