within methods for R environments

# S3 method for environment
within(data, expr, ..., quote = substitute(expr))

# S3 method for character
within(
  data,
  expr,
  ...,
  pos = 2L,
  warn.conflicts = TRUE,
  mask.ok = NULL,
  quote = substitute(expr)
)

Arguments

data

An R environment, or the name of a (potentially new) attached environment.

expr

The bare R expression to evaluate. Automatically quoted.

...

Ignored. Added for compatibility with the S3 generic. Throws an error if any arguments are passed to ....

quote

An R language object. This is an escape hatch from the automatic quoting of expr.

pos

The position where to attach the environment, if creating a new one. If an environment of name already exists, pos is ignored.

warn.conflicts

logical. If TRUE (the default), print warnings about objects in the attached environment that that are masking or masked by other objects of the same name.

mask.ok

character vector of names of objects that can mask objects on the search path without signaling a warning if warn.conflicts is TRUE.

Value

The R environment, invisibly.

Details

The only difference between attach_eval and within.character is the order of the arguments and the return value; the first returns the result of evaluating the expression, the latter the environment.

Note

See the note in attach_source about a potential pitfall of evaluating code directly in an attached environment.