[Rd] attaching to position 1
Patrick Burns
pburns at pburns.seanet.com
Wed Sep 22 19:30:10 CEST 2004
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
More information about the R-devel
mailing list