local_variables: "Variable generating" functions

View source: R/utilities.R

local_variablesR Documentation

"Variable generating" functions

Description

A pair of functions that allows a "variable generating" function and read this function's local vars into the environment of the caller.

Usage

local_variables(env = parent.frame())

localVariables(env = parent.frame())

source_variables(localVars)

sourceVariables(localVars)

Arguments

env

Parent environment

localVars

Result of function call exporting an environment

Value

Named vector of created local variables

The updated environment

Examples

myVariableGeneratingFunction <- function()
{
  x <- 1
  y <- 2
  local_variables()
}
myMainFunction <- function()
{
  source_variables(myVariableGeneratingFunction())
  print(c(x, y))
}

tidytidbits documentation built on March 18, 2022, 6:10 p.m.