evalFunctionOnList: Evaluate Function Under Local Variables

View source: R/evalFunctionOnList.r

evalFunctionOnListR Documentation

Evaluate Function Under Local Variables

Description

This function evaluates a function x under an environment which is created by a list. All elements of the list is local to the function; other words all elements of the list can be accessed directly by the function. A new environment is created and each element of variables is assigned to the new environment. Then the environment associated with the x is updated with the new environment. Finally x(...) is evaluated and return the result.

Usage

evalFunctionOnList(x, variables = list(), ..., parent_env)

Arguments

x

A function to be called

variables

A list to be converted to an environment

...

Further arguments to x

parent_env

parent environment

Value

Return value of the x(...).

Author(s)

TszKin Julian Chan ctszkin@gmail.com

See Also

environment

Examples

evalFunctionOnList(function() rnorm(n,mean,sd),list(n=5,mean=5,sd=1))

Jmisc documentation built on June 22, 2022, 9:09 a.m.