Skip to content
Prev 67669 / 398506 Next

Multiple copies of attached packages

I suspect you've attach()'ed `DF' multiple times in your
code (possibly inside a loop, or perhaps a function that 
was called several times).  Note that if it were a 
`package', it would show up in search() as `package:DF'
rather than just `DF'.  Also, R Core folks took care to
avoid attaching the same package multiple times:
[1] ".GlobalEnv"        "package:MASS"      "package:methods"
"package:stats"    
 [5] "package:graphics"  "package:grDevices" "package:utils"
"package:datasets" 
 [9] "Autoloads"         "package:base"
[1] ".GlobalEnv"        "package:MASS"      "package:methods"
"package:stats"    
 [5] "package:graphics"  "package:grDevices" "package:utils"
"package:datasets" 
 [9] "Autoloads"         "package:base"     

Notice how trying to load a package that's already on the
search path has no effect.

This is not true for R objects, though.

When you attach a data frame, say, `DF', (or a list), it
places a _copy_ on the search path, so you can access
the variables in the data frame (or components of the 
list) directly.  When you make modifications to the
variables (such as x[i] <- something, rather than
DF$x[i] <- something), the modifications are applied to 
the _copy_ on the search path, not the original.  

HTH,
Andy