Inspecting the environment
In R, every expression is evaluated within a specific environment. An environment is a collection of symbols and their bindings. When we bind a value to a symbol, call a function, or refer to a name, R will find the symbols in the current environment. If you type commands in the RStudio console, your commands are evaluated in the Global Environment.
For example, when we start a fresh R session in a terminal or RStudio, we start working within an empty global environment. In other words, there is no symbol defined in this environment. If we run x <- c(1, 2, 3)
, the numeric vector c(1, 2, 3)
is bound to symbol x
in the global environment. Then, the global environment has one binding that maps x
to the vector c(1, 2, 3)
. In other words, if you evaluate x
, then you will get its value.
Inspecting existing symbols
In addition to manipulating vectors and lists as we did in the previous chapter, we need to know some basic functions to inspect and manipulate our working...