formals {base} | R Documentation |
Get or set the formal arguments of a function.
formals(fun = sys.function(sys.parent())) formals(fun, envir = parent.frame()) <- value
fun |
a function object, or see Details. |
envir |
environment in which the function should be defined. |
value |
a list of R expressions. |
For the first form, fun
can be a character string
naming the function to be manipulated, which is searched for from the
parent environment.
If it is not specified, the function calling formals
is used.
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.
args
for a “human-readable” version,
alist
,
body
,
function
.
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