[R] result of mean(v1, v2, v3) of three real number not the same as sum(v1, v2, v3)/3

Eric Berger er|cjberger @end|ng |rom gm@||@com
Thu May 12 21:44:23 CEST 2022


Or ... to put it differently,, you need to wrap the numbers in c( .., ..,  )



On Thu, May 12, 2022 at 10:42 PM Ivan Krylov <krylov.r00t using gmail.com> wrote:

> On Thu, 12 May 2022 19:31:51 +0000
> "Sorkin, John" <jsorkin using som.umaryland.edu> wrote:
>
> > > mean(mlagFZ1,mlagFZ2,mlagFZ3)
> > [1] -0.3326792
>
> match.call(mean.default, quote(mean(mlagFZ1, mlagFZ2, mlagFZ3)))
> # mean(x = mlagFZ1, trim = mlagFZ2, na.rm = mlagFZ3)
>
> mean() takes a vector to compute a mean of and additional arguments,
> unlike sum(), which takes ... (almost arbitrary arguments) and sums all
> of them. Unfortunately, the "trim" argument is documented to accept any
> number and the na.rm argument is silently reinterpreted as logical in
> your case.
>
> --
> Best regards,
> Ivan
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list