From thomas@biostat.washington.edu  Sat May 24 00:09:59 1997
From: thomas@biostat.washington.edu (Thomas Lumley)
Date: Fri, 23 May 1997 16:09:59 -0700 (PDT)
Subject: R-alpha: var() and missing
In-Reply-To: <x2k9krh1hb.fsf@bush.kubism.ku.dk>
Message-ID: <Pine.SUN.3.95.970523160648.27149A-100000@data>



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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


R-alpha: var() and missing
Thomas Lumley