nargs                  package:base                  R Documentation

_T_h_e _N_u_m_b_e_r _o_f _A_r_g_u_m_e_n_t_s _t_o _a _F_u_n_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     When used inside a function body, 'nargs' returns the number of
     arguments supplied to that function, _including_ positional
     arguments left blank.

_U_s_a_g_e:

     nargs()

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'args', 'formals' and 'sys.call'.

_E_x_a_m_p_l_e_s:

     tst <- function(a, b = 3, ...) {nargs()}
     tst() # 0
     tst(clicketyclack) # 1 (even non-existing)
     tst(c1, a2, rr3) # 3

     foo <- function(x, y, z, w) {
        cat("call was", deparse(match.call()), "\n")
        nargs()
     }
     foo()    # 0
     foo(,,3) # 3
     foo(z=3) # 1, even though this is the same call

     nargs()# not really meaningful

