get_call | R Documentation |
get_call(env)
, given an environment associated with a currently
executing call, returns the function call and its arguments, as a
dots object. To replicate a call, the dots object returned can
be passed to do.
get_function(env)
finds the function object associated with a
currently executing call.
get_call( env = caller(environment()), ifnotfound = stop("get_call: environment not found on stack") ) get_function( env = caller(environment()), ifnotfound = stop("get_function: environment not found on stack") )
env |
An environment belonging to a currently executing
function call. By default, the caller of get_call itself
(so |
ifnotfound |
What to return if the call is not found. By default an error is thrown. |
get_call
is meant to replace match.call
and sys.call
;
its advantage is that it captures the environments bound to
arguments in addition to their written form.
get_function
is similar to sys.function
, but is keyed by
environment rather than number.
get_call
returns a dots object, the first element of
which represents the function name and caller environment.
get_function
returns a closure.
do dots caller
# We might think of re-writing the start of [lm] like so: LM <- function(formula, data, subset, weights, na.action, method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, contrasts = NULL, offset, ...) { cl <- get_call() mf <- do(model.frame, arg_list(formula, data, subset, weights, na.action, offset)) z <- get.call() class(z) <- c("LM", class(z)) z$call <- cl z } # and `update` like so: update.LM <- function(object, formula., ...) { call <- object$call extras <- dots(...) call$formula <- forced_quo(update.formula(formula(object), formula.)) do(call) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.