[R] Incorrectness of mean()

Claudia Beleites cbeleites at units.it
Mon Feb 28 11:34:58 CET 2011


On 02/28/2011 11:07 AM, zbynek.janoska at gmail.com wrote:
> I have found following problem: I have a vector:
>> a<- c(1.04,1.04,1.05,1.04,1.04)
> I want a mean of this vector:
>> mean(a)
> [1] 1.042 which is correct, but:
>> mean(1.04,1.04,1.05,1.04,1.04)
> [1] 1.04 gives an incorrect value. how is this possible?
the x that is averaged is only the first 1.04, the other numbers go into mean's
... argument and are ignored.

Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbeleites at units.it



More information about the R-help mailing list