[R] Incorrectness of mean()
Jim Lemon
jim at bitwrit.com.au
Mon Feb 28 11:31:51 CET 2011
On 02/28/2011 09:07 PM, 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?
Hi Zbynek,
You're asking the function to give you the mean of a single value. Try this:
mean(c(1.04,1.04,1.05,1.04,1.04))
Jim
More information about the R-help
mailing list