On Sat, Nov 17, 2012 at 4:56 PM, FJ M <chicagobrownb...@hotmail.com> wrote: > > attach(attach(dat)) > > should be > > attach(dat) > > Is attach() broken? I've been using attach() successfully for months. I was > surprised that header=TRUE did not map the headers to the data. But since > attach() worked, I've never asked for an enhancement to the various read > functions. >
No -- it's not broken, but it is dangerous (or more properly, confusing). It has non-local effects by creating a whole bunch of variables in the search path all at once. Combine that with the fact that those new variables can't be written to and an apparent sub/re-assignment really only creates global-environment copies (also somewhat magically) and you have a recipe for confusion. It's of course actually very important to the workings of R -- it's key to package loading, inter alia -- but in my alternate universe, it'd be hidden away, or at least start with a dot so it looks scarier. Michael ______________________________________________ R-help@r-project.org mailing list 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.