[R] result of mean(v1, v2, v3) of three real number not the same as sum(v1, v2, v3)/3
Sorkin, John
j@ork|n @end|ng |rom @om@um@ry|@nd@edu
Thu May 12 21:31:51 CEST 2022
I have a very strange problem. I am getting different results from
mean(mlagFZ1,mlagFZ2,mlagFZ3)
vs.
sum(mlagFZ1,mlagFZ2,mlagFZ3)/3
> mean(mlagFZ1,mlagFZ2,mlagFZ3)
[1] -0.3326792
> sum(mlagFZ1,mlagFZ2,mlagFZ3)/3
[1] -0.201942
R code:
print(mlagFZ1)
print(mlagFZ2)
print(mlagFZ3)
sum(mlagFZ1,mlagFZ2,mlagFZ3)/3
mean(mlagFZ1,mlagFZ2,mlagFZ3)
output;
> print(mlagFZ1)
[1] -0.3326792
> print(mlagFZ2)
[1] -0.1890601
> print(mlagFZ3)
[1] -0.0840866
> sum(mlagFZ1,mlagFZ2,mlagFZ3)/3
[1] -0.201942
> mean(mlagFZ1,mlagFZ2,mlagFZ3)
[1] -0.3326792
Can someone tell me what I did wrong?
More information about the R-help
mailing list