ID EN
Vector & List

call

R Base 3.6.2

Create or test for objects of mode "call" (or "(", see Details).

Syntax

R
call(name, …)
is.call(x)
as.call(x)

Arguments

Parameter Description
name a non-empty character string naming the function to be called.
… arguments to be part of the call.
x an arbitrary R object.

Details

call returns an unevaluated function call, that is, an unevaluated expression which consists of the named function applied to the given arguments (name must be a quoted string which gives the name of a function to be called). Note that although the call is unevaluated, the arguments … are evaluated.call is a primitive, so the first argument is taken as name and the remaining arguments as arguments for the constructed call: if the first argument is named the name must partially match name. is.call is used to determine whether x is a call (i.e., of mode "call" or "("). Note that is.call(x) is strictly equivalent to typeof(x) == "language". is.language() is also true for calls (but also for symbols and expressions where is.call() is false). as.call(x): Objects of mode "list" can be coerced to

Examples

Example
R
# NOT RUN {
is.call(call) #-> FALSE: Functions are NOT calls

## set up a function call to round with argument 10.5
cl <- call("round", 10.5)
is.call(cl) # TRUE
cl
identical(quote(round(10.5)), # <- less functional, but the same
          cl) # TRUE
## such a call can also be evaluated.
eval(cl) # [1] 10

class(cl) # "call"
typeof(cl)# "language"
is.call(cl) && is.language(cl) # always TRUE for "call"s

A <- 10.5
call("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 similar
f <- round
# }
# NOT RUN {
call(f, quote(A))  # error: first arg must be character
# }
# NOT RUN {
(g <- as.call(list(f, quote(A))))
eval(g)
## alternatively but less transparently
g <- list(f, quote(A))
mode(g) <- "call"
g
eval(g)
## see also the examples in the help for do.call
# }

See Also

do.call for calling a function by name and argument list; Recall for recursive calling of functions; further is.language expression function. Producing calls etc from character: str2lang and parse.