hasArg                package:methods                R Documentation

_L_o_o_k _f_o_r _a_n _A_r_g_u_m_e_n_t _i_n _t_h_e _C_a_l_l

_D_e_s_c_r_i_p_t_i_o_n:

     Returns 'TRUE' if 'name' corresponds to an argument in the call,
     either a formal argument to the function, or a component of '...',
     and 'FALSE' otherwise.

_U_s_a_g_e:

     hasArg(name)

_A_r_g_u_m_e_n_t_s:

    name: The unquoted name of a potential argument.

_D_e_t_a_i_l_s:

     The expression 'hasArg(x)', for example, is similar to
     '!missing(x)', with two exceptions.  First,  'hasArg' will look
     for an argument named 'x' in the call if 'x' is not a formal
     argument to the calling function, but '...' is.  Second, 'hasArg'
     never generates an error if given a name as an argument, whereas
     'missing(x)' generates an error if 'x' is not a formal argument.

_V_a_l_u_e:

     Always 'TRUE' or 'FALSE' as described above.

_S_e_e _A_l_s_o:

     'missing'

_E_x_a_m_p_l_e_s:

     ftest <- function(x1, ...) c(hasArg(x1), hasArg(y2))

     ftest(1) ## c(TRUE, FALSE)
     ftest(1, 2)  ## c(TRUE, FALSE)
     ftest(y2=2)   ## c(FALSE, TRUE)
     ftest(y=2)    ## c(FALSE, FALSE) (no partial matching)
     ftest(y2 = 2, x=1)  ## c(TRUE, TRUE) partial match x1

