na.fail                 package:base                 R Documentation

_H_a_n_d_l_e _M_i_s_s_i_n_g _V_a_l_u_e_s _i_n _O_b_j_e_c_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     These generic functions are useful for dealing with `NA's in e.g.,
     data frames. `na.fail' returns the object if it does not contain
     any missing values, and signals an error otherwise. `na.omit'
     returns the object with incomplete cases removed.

_U_s_a_g_e:

     na.fail(object)
     na.omit(object)

_A_r_g_u_m_e_n_t_s:

  object: an R object, typically a data frame

_D_e_t_a_i_l_s:

     At present these will handle vectors, matrices and data frames
     comprising vectors and matrices (only).

     If `na.omit' removes cases, the row numbers of the cases form the
     `"na.action"' attribute of the result, of class `"omit"'.

_S_e_e _A_l_s_o:

     `na.action', `options(na.action=..)' for setting ``NA actions'',
     and `lm' and `glm' for functions using these.

_E_x_a_m_p_l_e_s:

     DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA))
     na.omit(DF)
     m <- as.matrix(DF)
     na.omit(m)
     na.fail(DF)#> Error: missing values in ..

     options("na.action")

