formals {base}R Documentation

Access to and Manipulation of the Formal Arguments

Description

Get or set the formal arguments of a function.

Usage

formals(fun = sys.function(sys.parent()))
formals(fun) <- list

Arguments

fun a function object or a character string naming the function to be manipulated. If not specified, the function calling body is used.
list a list of R expressions.

Value

formals returns the formal argument list of the function specified.

The assignment form sets the formals of a function to the list on the right hand side.

See Also

args for a ``human-readable'' version, alist, body, function.

Examples

length(formals(lm))      # the number of formal arguments
names(formals(boxplot))  # formal arguments names

f <- function(x)a+b
formals(f) <- alist(a=,b=3) # function(a,b=3)a+b
f(2) # result = 5

[Package Contents]