call2 {rlang}R Documentation

Create a call

Description

Quoted function calls are one of the two types of symbolic objects in R. They represent the action of calling a function, possibly with arguments. There are two ways of creating a quoted call:

See section below for the difference between call2() and the base constructors.

Usage

call2(.fn, ..., .ns = NULL)

Arguments

.fn

Function to call. Must be a callable object: a string, symbol, call, or a function.

...

<dynamic> Arguments for the function call. Empty arguments are preserved.

.ns

Namespace with which to prefix .fn. Must be a string or symbol.

Difference with base constructors

call2() is more flexible and convenient than base::call():

Life cycle

In rlang 0.2.0 lang() was soft-deprecated and renamed to call2().

In early versions of rlang calls were called "language" objects in order to follow the R type nomenclature as returned by base::typeof(). The goal was to avoid adding to the confusion between S modes and R types. With hindsight we find it is better to use more meaningful type names.

See Also

call_modify

Examples

# fn can either be a string, a symbol or a call
call2("f", a = 1)
call2(quote(f), a = 1)
call2(quote(f()), a = 1)

#' Can supply arguments individually or in a list
call2(quote(f), a = 1, b = 2)
call2(quote(f), !!!list(a = 1, b = 2))

# Creating namespaced calls is easy:
call2("fun", arg = quote(baz), .ns = "mypkg")

# Empty arguments are preserved:
call2("[", quote(x), , drop = )

[Package rlang version 0.4.6 Index]