Test Two Objects for Full Equality - Generic function

DESCRIPTION:

Returns TRUE or a message about what is different between the two objects.

This function is an S Version 3 generic (see Methods); method functions can be written to handle specific S Version 3 classes of data. Classes which already have methods for this function include:
factor. In addition there is a default method.

USAGE:

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

REQUIRED ARGUMENTS:

target, current
two objects that are asserted to be the result of equivalent computations (for example, the same computation on two different computers, or a revised but still correct version of the same computation). By convention, the first argument is the supposedly correct version, typically from an object stored after earlier computation. The second argument is the result of a computation just completed, whose correctness is to be tested.

OPTIONAL ARGUMENTS:

tolerance
tolerance to be used to compare numeric components. Default is the square root of the machine precision for double precision computations, i.e., sqrt(.Machine$double.eps). The test used is on absolute difference if the target value is near zero and on relative difference otherwise, measured in mean absolute values (not mean square).

VALUE:

If all components and attributes of the two objects test equal, returns TRUE. Otherwise, returns a character vector giving all the discovered differences.

DETAILS:

The all.equal methods are fussy tests that will generally report any differences even those that might sometimes be considered irrelevant. For example, using dump on a function, then restore may result in an equivalent function with comments parsed differently (and which prints with different white space). The only substantial leniency in the default methods is that numerical equality is tested only up to tolerance. Additional leniency can be built in by writing methods for special classes of objects.

SEE ALSO:

, , , .

EXAMPLES:

new.fit <- update(old.fit) 
all.equal(new.fit,old.fit) 
# Compare two functions which may differ only in comment parsing 
reparse <- function(x) parse(text=deparse(x))[[1]] 
all.equal(reparse(f1), reparse(f2))