formals
Access and Manipulate the Formal Arguments

Description

Gets or sets the formal arguments of a function.

Usage

formals(fun = sys.function(sys.parent()), envir = parent.frame())
formals(fun, envir = parent.frame()) <- value

Arguments

fun a function object.
envir an environment where the function is defined.
value a list of expressions with named elements. The element names are the argument names and the values are the default argument values.

Details

When you call the function formals(), you can set the funargument to a character string giving the name of a function.
Value
returns a list where element names are the argument names, and their values are the default argument values.
Side Effects
The assignment function sets the formal arguments of the function to the list on the right-hand side. No consistency with current argument names or number is enforced or checked. All existing arguments are replaced by the new list of arguments.
See Also
args, functionArgs<-.
Examples
# Getting names of formal arguments
names(formals(sample))

# Setting formal arguments func <- function(x) a + b formals(func) <- list(a = NULL, b = 3) func(10)

Package base version 6.1.4-13
Package Index