Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Searching for Objects

Objects (data, functions, and methods) are searched for through a search path of packages and datasets. If the object is not found an error is raised. The search function will list the current search path. We add elements to the search path with the attach and library functions and can remove them with the detach function:

> Species
Error: object "Species" not found
> search()
 [1] ".GlobalEnv"        "package:Rcmdr"     "package:car"
 [4] "package:tcltk"     "package:methods"   "package:stats"
 [7] "package:graphics"  "package:grDevices" "package:utils"
[10] "package:datasets"  "RcmdrEnv"          "Autoloads"
[13] "package:base"
> attach(iris)
> search()
 [1] ".GlobalEnv"        "iris"              "package:Rcmdr"
 [4] "package:car"       "package:tcltk"     "package:methods"
 [7] "package:stats"     "package:graphics"  "package:grDevices"
[10] "package:utils"     "package:datasets"  "RcmdrEnv"
[13] "Autoloads"         "package:base"
> Species
  [1] setosa     setosa     setosa     setosa     setosa     setosa
[...]
[145] virginica  virginica  virginica  virginica  virginica  virginica
Levels: setosa versicolor virginica
> detach(iris)
> search()
 [1] ".GlobalEnv"        "package:Rcmdr"     "package:car"
 [4] "package:tcltk"     "package:methods"   "package:stats"
 [7] "package:graphics"  "package:grDevices" "package:utils"
[10] "package:datasets"  "RcmdrEnv"          "Autoloads"
[13] "package:base"



Copyright © 2004-2006 [email protected]
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware.