Learn R Programming

tidytidbits (version 0.3.2)

local_variables: "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

Run this code
# NOT RUN {
myVariableGeneratingFunction <- function()
{
  x <- 1
  y <- 2
  local_variables()
}
myMainFunction <- function()
{
  source_variables(myVariableGeneratingFunction())
  print(c(x, y))
}
# }

Run the code above in your browser using DataLab