[R] differing behavior of mean(), median() and sd() with na.rm
Ivan Calandra
c@l@ndr@ @ending from rgzm@de
Wed Aug 22 16:33:53 CEST 2018
Dear useRs,
I have just noticed that when input is only NA with na.rm=TRUE, mean()
results in NaN, whereas median() and sd() produce NA. Shouldn't it all
be the same? I think NA makes more sense than NaN in that case.
x <- c(NA, NA, NA) mean(x, na.rm=TRUE) [1] NaN median(x, na.rm=TRUE) [1]
NAsd(x, na.rm=TRUE) [1] NA
Thanks for any feedback.
Best,
Ivan
--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra
More information about the R-help
mailing list