Chapter 8. Symbols and Environments

So far, we’ve danced around the concept of environments without explicitly defining them. Every symbol in R is defined within a specific environment. An environment is an R object that contains the set of symbols available in a given context, the objects associated with those symbols, and a pointer to a parent environment. The symbols and associated objects are called a frame.

Every evaluation context in R is associated with an environment. When R attempts to resolve a symbol, it begins by looking through the current environment. If there is no match in the local environment, R will recursively search through parent environments looking for a match.

Get R in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.