[R] sum(NA,na.rm=T)

Jonathan Baron baron at cattell.psych.upenn.edu
Tue Apr 16 18:34:18 CEST 2002

This is zero!

That causes serious problems when I'm using sum() or mean() to
get the sum or mean of the non-missing data for each of several
subjects, some of whom have all data missing (on some variable),
and thus get a mean of 0.  E.g., with
some rows have all NA's, so the result I want is NA, but I get 0.

Is there an ELEGANT workaround that gives NA instead of 0?

Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list