feval: Evaluate a function

View source: R/helpers.R

fevalR Documentation

Evaluate a function

Description

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

Usage

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

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 Jan. 17, 2024, 2:42 p.m.