Re: [R] detach

From: Roger Peng <rdpeng_at_gmail.com>
Date: Wed 12 Jul 2006 - 23:14:03 EST

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@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@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/

______________________________________________
R-help@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
Received on Thu Jul 13 00:28:57 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 13 Jul 2006 - 04:21:36 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.