Possible inconsistency with mean & var

Wright, Kevin kevin.wright@pioneer.com
Tue, 1 Oct 2002 13:36:47 -0500


I encountered an unexpected difference in the way that mean and var work:

> mean(numeric(0))
[1] NaN

> var(numeric(0))
Error in var(numeric(0)) : `x' is empty

Looking into this, I discovered in mean.default that sum(x)/n
evaluates as
> sum(numeric(0))/length(numeric(0))
[1] NaN

The function var calls an .Internal and seems to evaluate this:
> .Internal(cov(numeric(0),NULL,"all.obs"))
Error: `x' is empty


Best,


Kevin Wright, Research Scientist
Pioneer Hi-Bred Int'l, x4054.




This communication is for use by the intended recipient and contains 
information that may be privileged, confidential or copyrighted under
applicable law.  If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited.  Please notify the sender
by return e-mail and delete this e-mail from your system.  Unless
explicitly and conspicuously designated as "E-Contract Intended",
this e-mail does not constitute a contract offer, a contract amendment,
or an acceptance of a contract offer.  This e-mail does not constitute
a consent to the use of sender's contact information for direct marketing
purposes or for transfers of data to third parties.

 Francais Deutsch Italiano  Espanol  Portuges  Japanese  Chinese  Korean

            http://www.DuPont.com/corp/email_disclaimer.html


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._