feval: Evaluate a function

Description Usage Arguments Examples

View source: R/helpers.R

Description

Evaluates a function by taking its argument values by name from the specified environment.

Usage

1
feval(fun, envir = parent.frame(), enclos = globalenv(), default = NULL)

Arguments

fun

Fuction to evaluate.

envir

Environment in which fun is to be evaluated. Must contain objects of the same name as the arguments in f.

enclos

Environment in which to look for objects not found in envir. Relevant only when envir is a (pair)list or data frame.

default

Default value (or function) to return (or evaluate) if requirements are not met.

Examples

1
2
3
4
5
6
7
f <- function(x) {x + 1}
feval(f, envir = list(x = 1))
feval(f, envir = list(y = 1))
## Not run: 
feval(f, envir = list(y = 1), default = function() stop("Arguments not found"))

## End(Not run)

columbia-glacier/cgr documentation built on Aug. 20, 2017, 5:49 p.m.