R-alpha: var() and missing

Thomas Lumley thomas@biostat.washington.edu
Fri, 23 May 1997 16:09:59 -0700 (PDT)



var() handles missing values in a very strange way. It is not what the
documentation says
> var(c(NA,1:10))
[1] 0
> var(1:10)
[1] 9.166667
This is because sum() handles NA incorrectly
> sum(NA)
[1] 0
> sum(NA,na.rm=T)
[1] 0
> sum(NA,na.rm=F)
[1] 0

Also the documentation gives a pairwise= option to var() which isn't in
the function.


Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel 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-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-