[Rd] attaching to position 1

From: Patrick Burns <pburns_at_pburns.seanet.com>
Date: Thu 23 Sep 2004 - 03:30:10 EST


If an attempt is made to attach to position 1, it appears to work (not even a warning) but in fact it doesn't work as many would expect. "search" thinks that it gets placed in position 2, but nothing is actually there (according to "ls").

This is guaranteed to be confusing (and annoying) to people who are used to attaching to position 1 in S-PLUS.

I'm not clear on all of the implications of changing this, but my first inclination would be to make it an error to attach to position 1. The help file says that you can't do it.

At the very least there should be a warning . My guess is that it is rare for someone to attach to position 1 and not attempt to modify what is being attached.

> attach('foo.RData')
> search()

 [1] ".GlobalEnv"        "file:foo.RData"    "package:methods" 
 [4] "package:stats"     "package:graphics"  "package:grDevices"
 [7] "package:utils"     "package:datasets"  "Autoloads"       
[10] "package:base"
> ls(2)

[1] "jj"
> jj

[1] 1 2 3 4 5 6 7 8 9
> detach()
> search()
[1] ".GlobalEnv"        "package:methods"   "package:stats"   
[4] "package:graphics"  "package:grDevices" "package:utils"   
[7] "package:datasets"  "Autoloads"         "package:base"    

> attach('foo.RData', pos=1)
> search()
 [1] ".GlobalEnv"        "file:foo.RData"    "package:methods" 
 [4] "package:stats"     "package:graphics"  "package:grDevices"
 [7] "package:utils"     "package:datasets"  "Autoloads"       
[10] "package:base"
> ls(2)

character(0)
         _                          
platform i386-pc-mingw32            
arch     i386                       
os       mingw32                    
system   i386, mingw32              
status   Under development (unstable)
major    2                          
minor    0.0                        
year     2004                       
month    09                         
day      17                         

language R

Pat



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Sep 23 03:35:59 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:00:22 EST