As above, anyone knows what is happening?
m1 <- 0.457842055395572
m2 <- 0.587127416942505
sum(m1, m2)/2
mean(m1, m2)
Output:
> m1 <- 0.457842055395572
> m2 <- 0.587127416942505
> sum(m1, m2)/2
[1] 0.5224847
> mean(m1, m2)
[1] 0.4578421
Restarted R and still the same. Am on R 3.0 x86 Windows.
mean
is an S3 function that takes a single main argument which is a single R object (most commonly a vector) of quantities, and any other arguments get passed on to other methods through ...
. In this they get passed onto mean.default
which has two extra named arguments, trim
and na.rm
. Therefore your second value will be interpreted as the trim amount (though you can't trim a single value).
What you want to type is:
mean(c(m1, m2))
[1] 0.5224847
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With