formals package:base R Documentation _A_c_c_e_s_s _t_o _a_n_d _M_a_n_i_p_u_l_a_t_i_o_n _o_f _t_h_e _F_o_r_m_a_l _A_r_g_u_m_e_n_t_s _D_e_s_c_r_i_p_t_i_o_n: Get or set the formal arguments of a function. _U_s_a_g_e: formals(fun = sys.function(sys.parent())) formals(fun, envir = environment(fun)) <- value _A_r_g_u_m_e_n_t_s: fun: a function object, or see 'Details'. envir: environment in which the function should be defined. value: a list (or pairlist) of R expressions. _D_e_t_a_i_l_s: For the first form, 'fun' can also 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. Only _closures_ have formals, not primitive functions. _V_a_l_u_e: 'formals' returns the formal argument list of the function specified, as a 'pairlist', or 'NULL' for a non-function or primitive. The replacement form sets the formals of a function to the list/pairlist on the right hand side, and (potentially) resets the environment of the function. _S_e_e _A_l_s_o: 'args' for a human-readable version, 'alist', 'body', 'function'. _E_x_a_m_p_l_e_s: require(stats); require(graphics) 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