na.fail package:stats 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. 'na.pass' returns the object unchanged. _U_s_a_g_e: na.fail(object, ...) na.omit(object, ...) na.exclude(object, ...) na.pass(object, ...) _A_r_g_u_m_e_n_t_s: object: an R object, typically a data frame ...: further arguments special methods could require. _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"'. 'na.exclude' differs from 'na.omit' only in the class of the '"na.action"' attribute of the result, which is '"exclude"'. This gives different behaviour in functions making use of 'naresid' and 'napredict': when 'na.exclude' is used the residuals and predictions are padded to the correct length by inserting 'NA's for cases omitted by 'na.exclude'. _R_e_f_e_r_e_n_c_e_s: Chambers, J. M. and Hastie, T. J. (1992) _Statistical Models in S._ Wadsworth & Brooks/Cole. _S_e_e _A_l_s_o: 'na.action'; 'options' with argument 'na.action' for setting NA actions; and 'lm' and 'glm' for functions using these. 'na.contiguous' as alternative for time series. _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) stopifnot(all(na.omit(1:3) == 1:3)) # does not affect objects with no NA's try(na.fail(DF))#> Error: missing values in ... options("na.action")