October 2012
Beginner to intermediate
721 pages
21h 38m
English
Like everything else in R, environments are objects. Internally, R stores symbol mappings in hash tables. In Chapter 24, I’ll show how some tricks for using environment objects to write efficient R code.
Table 8-1 shows the functions in R for manipulating environment objects.
Table 8-1. Manipulating environment objects
| Function | Description |
|---|---|
assign | Assigns the name x to the object value in the environment envir. |
get | Gets the object associated with the name x in the environment envir. |
exists | Checks that the name x is defined in the environment envir. |
objects | Returns a vector of all names defined in the
environment envir. |
remove | Removes the list of objects in the argument list
from the environment envir.
(List is an unfortunate argument name, especially as the argument
needs to be a vector.) |
search | Returns a vector containing the names of attached packages. You can think of this as the search path in which R tries to resolve names. More precisely, it shows the list of chained parent environments. |
searchpaths | Returns a vector containing the paths of attached packages. |
attach | Adds the objects in the list, data frame, or data
file what to the current search
path. |
detach | Removes the objects in the list, data frame, or data
file what from the current
search path. |
emptyenv | Returns the empty environment object. All environments chain back to this object. |
parent.env | Returns the parent of environment env. |
baseenv | The environment of the base package. |
globalenv or .GlobalEnv | Returns the environment ... |