[R] detach

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jul 11 20:04:32 CEST 2006


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



More information about the R-help mailing list