e2l {str2str}R Documentation

Environment to List

Description

e2l converts an environment to a list. The function assumes you don't want *all* objects in an environment and uses pick to determine which objects you want included. If you want all objects in an environment, then use grab(x = objects(envir, all.names = TRUE), envir).

Usage

e2l(
  e = sys.frame(),
  val,
  pat = FALSE,
  not = FALSE,
  fixed = FALSE,
  sorted = FALSE,
  check = TRUE
)

Arguments

e

environment to pull the objects from. Default is the global environment.

val

character vector specifying which objects from e will be extracted. If pat = FALSE (default), then val can have length > 1, and exact matching will be done via is.element (essentially match). If pat = TRUE, then val has to be a character vector of length 1 and partial matching will be done via grepl with the option of regular expressions if fixed = FALSE (default).

pat

logical vector of length 1 specifying whether val should refer to exact matching (FALSE) via is.element (essentially match) or partial matching (TRUE) and/or use of regular expressions via grepl. See details for a brief description of some common symbols and help(regex) for more.

not

logical vector of length 1 specifying whether val indicates values that should be retained (FALSE) or removed (TRUE).

fixed

logical vector of length 1 specifying whether val refers to values as is (TRUE) or a regular expression (FALSE). Only used if pat = TRUE.

sorted

logical vector of length 1 specifying whether the objects should be sorted alphanumerically. If FALSE, the objects are usually in the order they were initially created, but not always (see help(objects)).

check

logical vector of length 1 specifying whether to check the structure of the input arguments. For example, check whether e is an environment. This argument is available to allow flexibility in whether the user values informative error messages (TRUE) vs. computational efficiency (FALSE).

Value

list with object contents from environment e with names as the object names.

Examples

model_1 <- lm(v2frm(names(attitude)), data = attitude)
model_2 <- lm(v2frm(names(mtcars)), data = mtcars)
model_3 <- lm(v2frm(names(airquality)), data = airquality)
e2l(val = "model_", pat = TRUE)

[Package str2str version 1.0.0 Index]