| call | R Documentation |
Create or test for objects ofmode"call" (or"(", see Details).
call(name, ...)is.call(x)as.call(x)
name | a non-empty character string naming the function to be called. |
... | arguments to be part of the call. |
x | an arbitraryR object. |
callreturns an unevaluated function call, that is, anunevaluated expression which consists of the named function applied tothe given arguments (name must be a string which givesthe name of a function to be called). Note that although the call isunevaluated, the arguments... are evaluated.
call is a primitive, so the first argument istaken asname and the remaining arguments as arguments for theconstructed call: if the first argument is named the name mustpartially matchname.
is.callis used to determine whetherx is a call (i.e.,of mode"call" or"("). Note that
is.call(x) is strictly equivalent totypeof(x) == "language".
is.language() is also true for calls (but alsoforsymbols andexpressions whereis.call() is false).
as.call(x):Objects of mode"list" can be coerced to mode"call".The first element of the list becomes the function part of the call,so should be a function or the name of one (as a symbol; a character string will not do).
If you think of usingas.call(<string>), consider usingstr2lang(*) which is an efficient version ofparse(text=*).Note thatcall() andas.call(), whenapplicable, are much preferable to theseparse() basedapproaches.
All three are primitive functions.
as.call is generic: you can write methods to handle specificclasses of objects, see InternalMethods.
call should not be used to attempt to evade restrictions on theuse of.Internal and other non-API calls.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.
do.call for calling a function by name and argumentlist;Recall for recursive calling of functions;furtheris.language,expression,function.
Producingcalls etc from character:str2lang andparse.
is.call(call) #-> FALSE: Functions are NOT calls## set up a function call to round with argument 10.5cl <- call("round", 10.5)is.call(cl) # TRUEclidentical(quote(round(10.5)), # <- less functional, but the same cl) # TRUE## such a call can also be evaluated.eval(cl) # [1] 10class(cl) # "call"typeof(cl)# "language"is.call(cl) && is.language(cl) # always TRUE for "call"sA <- 10.5call("round", A) # round(10.5)call("round", quote(A)) # round(A)f <- "round"call(f, quote(A)) # round(A)## if we want to supply a function we need to use as.call or similarf <- round## Not run: call(f, quote(A)) # error: first arg must be character(g <- as.call(list(f, quote(A))))eval(g)## alternatively but less transparentlyg <- list(f, quote(A))mode(g) <- "call"geval(g)## see also the examples in the help for do.callAdd the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.