On 08/23/2018 06:15 PM, Ivan Calandra wrote:
Thanks all for the enlightenment.
So, it does make sense that mean() produces NaN and median()/sd() NA,
from a calculation point of view at least.
But I still think it also makes sense that the mean of NA is NA as well,
be it only for consistency with other functions. That's just my opinion
of course. I can still convert NaN to NA at the end if I need to.
But the mean of NA *is* NA!
x <- NA
mean(x)
[1] NA
This is *not* the same scenario as having nothing left after *removing*
all NAs:
x <- rep(NA,3)
mean(x,na.rm=TRUE > [1] NaN
Seems quite consistent/coherent to me.
cheers,
Rolf Turner
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.