Modify the arguments of a call.

call_modify(call, new_args, env = parent.frame())

call_standardise(call, env = parent.frame())

Arguments

call

A call to modify. It is first standardised with call_standardise.

new_args

A named list of expressions (constants, names or calls) used to modify the call. Use NULL to remove arguments.

env

Environment in which to look up call value.

Examples

call <- quote(mean(x, na.rm = TRUE))
call_standardise(call)
#> mean(x = x, na.rm = TRUE)

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

# Remove an argument
call_modify(call, list(na.rm = NULL))
#> mean(x = x)

# Add a new argument
call_modify(call, list(trim = 0.1))
#> mean(x = x, na.rm = TRUE, trim = 0.1)

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