[Rd] attach "warning" is a message

Barry Rowlingson b@row||ng@on @end|ng |rom |@nc@@ter@@c@uk
Mon Aug 9 16:06:34 CEST 2021


If I mask something via `attach`:

> d = data.frame(x=1:10)
> x=1
> attach(d)
The following object is masked _by_ .GlobalEnv:

    x
>

I get that message. The documentation for `attach` uses the phrase
"warnings", although the message isn't coming from `warning()`:

warn.conflicts: logical.  If ‘TRUE’, warnings are printed about
          ‘conflicts’ from attaching the database, unless that database
          contains an object ‘.conflicts.OK’.  A conflict is a function
          masking a function, or a non-function masking a non-function.

and so you can't trap them with options(warn=...) and so on. This sent me
briefly down the wrong track while trying to figure out why R was showing a
masking error in one context but not another - I wondered if I'd supressed
warning()s in the other context.

Personally I'd like these messages to be coming from warning() since that
seems the appropriate way to warn someone they've done something which
might have unwanted effects. But fixing the documentation to say "If
‘TRUE’, *messages* are printed" is probably less likely to break existing
code.

Happy to add something to bugzilla if anyone thinks I'm not being overly
pedantic here.

Barry

	[[alternative HTML version deleted]]



More information about the R-devel mailing list