[R] a very small query

Gabor Grothendieck ggrothendieck at gmail.com
Mon Mar 26 15:40:24 CEST 2007


Try these:

search()
sessionInfo()
loadedNamespaces()

The first two show the attached packages (and some other info) and the
last one shows the namespaces that are loaded.  Note that detaching
a package does not unload its namespace and unloading a namespace
does not de-register its methods.  This illustrates the behavior:

> search()
[1] ".GlobalEnv"        "package:stats"     "package:graphics"
[4] "package:grDevices" "package:utils"     "package:datasets"
[7] "package:methods"   "Autoloads"         "package:base"
> loadedNamespaces()
[1] "base"      "graphics"  "grDevices" "methods"   "stats"     "utils"
> as.Date(1) # error as there is no numeric method for as.Date
Error in as.Date.default(1) : do not know how to convert '1' to class "Date"

> library(zoo)
> search()
 [1] ".GlobalEnv"        "package:zoo"       "package:stats"
 [4] "package:graphics"  "package:grDevices" "package:utils"
 [7] "package:datasets"  "package:methods"   "Autoloads"
[10] "package:base"
> loadedNamespaces()
[1] "base"      "graphics"  "grDevices" "grid"      "lattice"   "methods"
[7] "stats"     "utils"     "zoo"
> as.Date(1) # zoo defines a numeric method for as.Date
[1] "1970-01-02"

> detach()
> unloadNamespace("zoo")
<environment: namespace:zoo>
> search()
[1] ".GlobalEnv"        "package:stats"     "package:graphics"
[4] "package:grDevices" "package:utils"     "package:datasets"
[7] "package:methods"   "Autoloads"         "package:base"
> loadedNamespaces()
[1] "base"      "graphics"  "grDevices" "grid"      "lattice"   "methods"
[7] "stats"     "utils"
> # zoo is gone from attached package list and loadedNamespaces
> # but numeric method for as.Date from zoo is still registered
> as.Date(1)
[1] "1970-01-02"



On 3/26/07, gyadav at ccilindia.co.in <gyadav at ccilindia.co.in> wrote:
>
> Hi All
>
> what is the command to give me the listing of the loaded packages. I mean
> which are active and not the listing of all the installed packages as
> given by library()
>
> thanks in advance
> -gaurav
>
>
> ============================================================================================
> DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}}
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list