all.equal package:base R Documentation _T_e_s_t _i_f _T_w_o _O_b_j_e_c_t_s _a_r_e (_N_e_a_r_l_y) _E_q_u_a_l _D_e_s_c_r_i_p_t_i_o_n: 'all.equal(x,y)' is a utility to compare R objects 'x' and 'y' testing 'near equality'. If they are different, comparison is still made to some extent, and a report of the differences is returned. Don't use 'all.equal' directly in 'if' expressions-either use 'isTRUE(all.equal(....))' or 'identical' if appropriate. _U_s_a_g_e: all.equal(target, current, ...) ## S3 method for class 'numeric': all.equal(target, current, tolerance = .Machine$double.eps ^ 0.5, scale = NULL, check.attributes = TRUE, ...) attr.all.equal(target, current, check.attributes = TRUE, check.names = TRUE, ...) _A_r_g_u_m_e_n_t_s: target: R object. current: other R object, to be compared with 'target'. ...: Further arguments for different methods, notably the following two, for numerical comparison: tolerance: numeric >= 0. Differences smaller than 'tolerance' are not considered. scale: numeric scalar > 0 (or 'NULL'). See 'Details'. check.attributes: logical indicating if the 'attributes(.)' of 'target' and 'current' should be compared as well. check.names: logical indicating if the 'names(.)' of 'target' and 'current' should be compared as well (and separately from the 'attributes'). _D_e_t_a_i_l_s: There are several methods available, most of which are dispatched by the default method, see 'methods("all.equal")'. 'all.equal.list' and 'all.equal.language' provide comparison of recursive objects. Numerical comparisons for 'scale = NULL' (the default) are done by first computing the mean absolute difference of the two numerical vectors. If this is smaller than 'tolerance' or not finite, absolute differences are used, otherwise relative differences scaled by the mean absolute difference. If 'scale' is positive, absolute comparisons are made after scaling (dividing) by 'scale'. For complex arguments, the modulus 'Mod' of the difference is used: 'all.equal.numeric' is called so arguments 'tolerance' and 'scale' are available. 'attr.all.equal' is used for comparing 'attributes', returning 'NULL' or a 'character' vector. _V_a_l_u_e: Either 'TRUE' ('NULL' for 'attr.all.equal') or a vector of 'mode' '"character"' describing the differences between 'target' and 'current'. _R_e_f_e_r_e_n_c_e_s: Chambers, J. M. (1998) _Programming with Data. A Guide to the S Language_. Springer (for '='). _S_e_e _A_l_s_o: 'identical', 'isTRUE', '==', and 'all' for exact equality testing. _E_x_a_m_p_l_e_s: all.equal(pi, 355/113) # not precise enough (default tol) > relative error d45 <- pi*(1/4 + 1:10) stopifnot( all.equal(tan(d45), rep(1,10))) # TRUE, but all (tan(d45) == rep(1,10)) # FALSE, since not exactly all.equal(tan(d45), rep(1,10), tol=0) # to see difference