[R] Handling "NA" in summation

Olu Ola oluola2011 at yahoo.com
Mon Sep 7 00:22:32 CEST 2015

I am currently working with a dataframe which has some missing values represented by "NA". whenever, I add two columns in which at least one of the pair of an observation is "NA", the sum returns zero. That is for the same observation, if 

dataframe$A = 20
dataframe$B = NA

dataframe$A + dataframe$B  returns zero.

I do not want to delete the observations with the NA's. How do I go about carrying out the necessary operations without deleting the observations with the NA's

Thank you

More information about the R-help mailing list