missing                 package:base                 R Documentation

_D_o_e_s _a _F_o_r_m_a_l _A_r_g_u_m_e_n_t _h_a_v_e _a _V_a_l_u_e?

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

     `missing' can be used to test whether a value was specified as an
     argument to a function.

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

     missing(x)

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

       x: a formal argument.

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

     `missing(x)' is only reliable if `x' has not been altered since
     entering the function: in particular it will always be true after
     `x <- match.arg(x)'. 

     The example shows how a plotting function can be written to work
     with either a pair of vectors giving x and y coordinates of points
     to be plotted or a single vector giving y values to be plotted
     against their indexes.

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

     `substitute' for argument expression; `NA' for ``missing values''
     in data.

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

     myplot <- function(x,y) {
                     if(missing(y)) {
                             y <- x
                             x <- 1:length(y)
                     }
                     plot(x,y)
             }

