[R] detach
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Jul 12 15:21:26 CEST 2006
Note that even this entered into a fresh session exhibits this
behavior. There is no use of ::: here:
> as.Date(1)
Error in as.Date.default(1) : do not know how to convert '1' to class "Date"
> library(zoo)
> as.Date(1)
[1] "1970-01-02"
> unloadNamespace("zoo")
<environment: namespace:zoo>
> as.Date(1)
[1] "1970-01-02"
> R.version.string
[1] "Version 2.3.1 Patched (2006-06-04 r38279)"
> packageDescription("zoo")$Version
[1] "1.1-1"
On 7/12/06, Roger Peng <rdpeng at gmail.com> wrote:
> I believe (3) should always work as long as zoo has a namespace. The
> ':::' operator will load the namespace of the package but will not
> attach it to the search list.
>
> -roger
>
> On 7/11/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> > We try the following:
> >
> > search()
> > as.Date(1)
> > zoo:::as.Date.numeric
> >
> > under three circumstances:
> >
> > 1. on a fresh session
> > 2. after issuing library(zoo) noting that as.Date.numeric is provided by zoo
> > 3. after detaching zoo
> >
> > as.Date(1) fails on #1 but succeeds in #2 and #3. Should it not fail in #3
> > since zoo was detached? Is this how its supposed to work?
> >
> > (Note that entering zoo:::as.Date.numeric at the console
> > succeeds in displaying the function in all three cases.)
> >
> > Here is the console session:
> >
> > > R.version.string # XP
> > [1] "Version 2.3.1 Patched (2006-06-04 r38279)"
> > >
> > > search()
> > [1] ".GlobalEnv" "package:methods" "package:stats"
> > [4] "package:graphics" "package:grDevices" "package:utils"
> > [7] "package:datasets" "Autoloads" "package:base"
> > > as.Date(1)
> > Error in as.Date.default(1) : do not know how to convert '1' to class "Date"
> > > zoo:::as.Date.numeric
> > function (x, ...)
> > structure(floor(x + 0.001), class = "Date")
> > <environment: namespace:zoo>
> > >
> > > library(zoo)
> > > search()
> > [1] ".GlobalEnv" "package:zoo" "package:methods"
> > [4] "package:stats" "package:graphics" "package:grDevices"
> > [7] "package:utils" "package:datasets" "Autoloads"
> > [10] "package:base"
> > > as.Date(1)
> > [1] "1970-01-02"
> > > zoo:::as.Date.numeric
> > function (x, ...)
> > structure(floor(x + 0.001), class = "Date")
> > <environment: namespace:zoo>
> > >
> > > detach()
> > > search()
> > [1] ".GlobalEnv" "package:methods" "package:stats"
> > [4] "package:graphics" "package:grDevices" "package:utils"
> > [7] "package:datasets" "Autoloads" "package:base"
> > > as.Date(1)
> > [1] "1970-01-02"
> > > zoo:::as.Date.numeric
> > function (x, ...)
> > structure(floor(x + 0.001), class = "Date")
> > <environment: namespace:zoo>
> > >
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >
>
>
> --
> Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/
>
More information about the R-help
mailing list