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.

_U_s_a_g_e:

     all.equal(target, current, ...)

     all.equal.numeric(target, current,
                       tolerance= .Machine$double.eps ^ 0.5, scale=NULL)

_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 comparison is done using averge (`mean') relative error,
     unless `scale' is used or when the absolute difference is less
     than `tolerance'. For complex arguments, `Mod' of difference is
     used.

     `attr.all.equal' is used for comparing `attributes', returning
     `NULL' or `character'.

_V_a_l_u_e:

     Either `TRUE' or a vector of `mode' `"character"' describing the
     differences between `target' and `current'.

     Numerical differences are reported by relative error

_S_e_e _A_l_s_o:

     `==', 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

     stopifnot(
     all.equal(gamma(2:14),   cumprod(1:13))) # TRUE, but

     all      (gamma(2:14) == cumprod(1:13)) # FALSE, since not exactly
     all.equal(gamma(2:14),   cumprod(1:13), tol=0) # to see difference

     all.equal(options(), .Options)
     all.equal(options(), as.list(.Options))# TRUE
     .Options $ myopt <- TRUE
     all.equal(options(), as.list(.Options))
     rm(.Options)

