Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

do.call: Execute a Function Call

do.callR Documentation

Execute a Function Call

Description

do.call constructs and executes a function call from a name ora function and a list of arguments to be passed to it.

Usage

do.call(what, args, quote = FALSE, envir = parent.frame())

Arguments

what

either a function or a non-empty character string naming thefunction to be called.

args

alist of arguments to the function call. Thenames attribute ofargs gives the argument names.

quote

a logical value indicating whether to quote thearguments.

envir

an environment within which to evaluate the call. Thiswill be most useful ifwhat is a character string andthe arguments are symbols or quoted expressions.

Details

Ifquote isFALSE, the default, then the arguments areevaluated (in the calling environment, not inenvir). Ifquote isTRUE then each argument is quoted (seequote) so that the effect of argument evaluation is toremove the quotes – leaving the original arguments unevaluated when thecall is constructed.

The behavior of some functions, such assubstitute,will not be the same for functions evaluated usingdo.call asif they were evaluated from the interpreter. The precise semanticsare currently undefined and subject to change.

Value

The result of the (evaluated) function call.

Warning

This should not be used to attempt to evade restrictions on the use of.Internal and other non-API calls.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.

See Also

call which creates an unevaluated call.

Examples

do.call("complex", list(imaginary = 1:3))## if we already have a list (e.g., a data frame)## we need c() to add further argumentstmp <- expand.grid(letters[1:2], 1:3, c("+", "-"))do.call("paste", c(tmp, sep = ""))do.call(paste, list(as.name("A"), as.name("B")), quote = TRUE)## examples of where objects will be found.A <- 2f <- function(x) print(x^2)env <- new.env()assign("A", 10, envir = env)assign("f", f, envir = env)f <- function(x) print(x)f(A)                                      # 2do.call("f", list(A))                     # 2do.call("f", list(A), envir = env)        # 4do.call( f,  list(A), envir = env)        # 2do.call("f", list(quote(A)), envir = env) # 100do.call( f,  list(quote(A)), envir = env) # 10do.call("f", list(as.name("A")), envir = env) # 100eval(call("f", A))                      # 2eval(call("f", quote(A)))               # 2eval(call("f", A), envir = env)         # 4eval(call("f", quote(A)), envir = env)  # 100

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2025 Movatter.jp