Modify the arguments of a call

Modify the arguments of a call

call_modify(.call, ..., .standardise = FALSE, .env = caller_env())

Can be a call, a formula quoting a call in the right-hand side, or a frame object from which to extract the call expression.


Named or unnamed expressions (constants, names or calls) used to modify the call. Use NULL to remove arguments. These dots support tidy dots features.


If TRUE, the call is standardised beforehand to match existing unnamed arguments to their argument names. This prevents new named arguments from accidentally replacing original unnamed arguments.


The environment where to find the call definition in case call is not wrapped in a quosure. This is passed to call_standardise() if .standardise is TRUE.


A quosure if .call is a quosure, a call otherwise.

Life cycle

In rlang 0.2.0, lang_modify() was soft-deprecated and renamed to call_modify(). See lifecycle section in call2() for more about this change.

See Also


  • call_modify
call <- quote(mean(x, na.rm = TRUE))

# Modify an existing argument
call_modify(call, na.rm = FALSE)
call_modify(call, x = quote(y))

# Remove an argument
call_modify(call, na.rm = NULL)

# Add a new argument
call_modify(call, trim = 0.1)

# Add an explicit missing argument
call_modify(call, na.rm = quote(expr = ))

# Supply a list of new arguments with `!!!`
newargs <- list(na.rm = NULL, trim = 0.1)
call_modify(call, !!! newargs)

# Supply a call frame to extract the frame expression:
f <- function(bool = TRUE) {
  call_modify(call_frame(), splice(list(bool = FALSE)))

# You can also modify quosures inplace:
f <- quo(matrix(bar))
call_modify(f, quote(foo))
# }
Documentation reproduced from package rlang, version 0.2.2, License: GPL-3

Community examples

Looks like there are no examples yet.