[R] detach
Roger Peng
rdpeng at gmail.com
Wed Jul 12 15:14:03 CEST 2006
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