View source: R/datautilities.R
sumna | R Documentation |
sum a vector or numeric variable correctly accounting for NA
sumna(x)
x |
A numeric vector |
returns NA only of all are NA, otherwise returns sum of non missing value
compare to sum(x, na.rm=TRUE) which returns 0 if all values are NA
x<-c(rep(NA, 5))
sum(x, na.rm=TRUE)
sumna(x)
y<-c(rep(NA, 5), 1, 2, 3)
sumna(y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.