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

