Modify the arguments of a call

lang_modify(.lang, ..., .standardise = FALSE)



Can be a call (language object), 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. Dots are evaluated with explicit splicing.


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


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

See also



call <- quote(mean(x, na.rm = TRUE)) # Modify an existing argument lang_modify(call, na.rm = FALSE)
#> mean(x, na.rm = FALSE)
lang_modify(call, x = quote(y))
#> mean(x, na.rm = TRUE, x = y)
# Remove an argument lang_modify(call, na.rm = NULL)
#> mean(x)
# Add a new argument lang_modify(call, trim = 0.1)
#> mean(x, na.rm = TRUE, trim = 0.1)
# Add an explicit missing argument lang_modify(call, na.rm = quote(expr = ))
#> mean(x, na.rm = )
# Supply a list of new arguments with splice() newargs <- list(na.rm = NULL, trim = 0.1) lang_modify(call, splice(newargs))
#> mean(x, trim = 0.1)
# Supply a call frame to extract the frame expression: f <- function(bool = TRUE) { lang_modify(call_frame(), splice(list(bool = FALSE))) } f()
#> f(bool = FALSE)
# You can also modify quosures inplace: f <- ~matrix(bar) lang_modify(f, quote(foo))
#> ~matrix(bar, foo) #> <environment: 0x7f979a31fe28>