[Rd] attach and object masking

From: Martyn Plummer <plummer_at_iarc.fr>
Date: Fri 10 Jun 2005 - 16:12:33 GMT

The library() function prints an information message when objects are masked on the search path by (or from) a newly attached package. The attach() function, however, doesn't. Is there a good reason for this? I have adapted the machinery for checking conflicts used in the library () function to attach(). If there are no objections, I will check this into R-devel.

I have seen new users get into terrible trouble with attach, e.g. 1) attaching the same database multiple times, or 2) Masking a vector in an attached data frame with a transformed version in the global environment and *then* re-running a script that transforms the transformed variable. For example, run this snippet twice and you might get a surprise.

foo <- data.frame(x=1:10)
x <- x/2

A warning would certainly help.

Incidentally, (1) occurs in the example for the beavers data set. I didn't find any other problems.

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Jun 11 02:18:23 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:09 GMT