[R] Weird Behavior of mean

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Fri Dec 13 21:48:27 CET 2024


  This example is a little more subtle than that; the OP knows about
name masking, but was expecting T to be coerced to logical, which
would ordinarily be a reasonable expectation (IMO) ...

On Fri, Dec 13, 2024 at 3:40 PM Jeff Newmiller via R-help
<r-help using r-project.org> wrote:
>
> This was documented in [1] forever ago. I would not miss it if a future version of R chose to remove those variables.
>
> [1] The R Inferno, 8.1.32
>
> On December 13, 2024 11:21:13 AM PST, ivo welch <ivo.welch using ucla.edu> wrote:
> >isn't this still a little R buglet?  I have overwritten T (even if my
> >schuld [franconian], it is not that uncommon an error, because T is also a
> >common abbreviation for the end of a time series; namespace pollution in R
> >can be quite annoying, even though I understand that it is convenient in
> >interactive mode).  Nevertheless, I am passing into mean() a positive
> >number for na.rm, and by definition, a positive number still means TRUE.
> > besides, sd() and mean() should probably treat this similarly, anyway.  I
> >do see the argument that functions cannot be proof against redefinitions of
> >all sorts of objects that they can use.    more philosophically, some
> >variables should not be overwritable, or at least trigger a warning.
> >
> >As Dante wrote, Abandon all hope ye who enter R.
> >
> >--
> >Ivo Welch (ivo.welch using ucla.edu)
> >
> >       [[alternative HTML version deleted]]
> >
> >______________________________________________
> >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 https://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> ______________________________________________
> 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 https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list