Here is one way to accomplish this:
#make a data frame
df <- data.frame(a = c(1,2,3),
b = c(1,NA,3),
c = c(1,2,3))
#use rowSums on a dataframe made with each of your columns and specify na.rm = TRUE
df$mySum <- rowSums(cbind(df$a,df$b), na.rm = TRUE)
0
solved Row-wise sum for select columns while ignoring NAs [closed]