compareShorten {compare} | R Documentation |
Compare Two Objects with Different Lengths
Description
Compare two objects for equality, shortening either one if necessary beforehand.
Usage
compareShorten(model, comparison, transform = character(),
equal = TRUE, ...)
## S3 method for class 'data.frame'
compareShorten(model, comparison, transform=character(),
equal=TRUE, colsOnly=TRUE,
ignoreColOrder=FALSE, ignoreNameCase=FALSE, ...)
Arguments
model |
The “correct” object. |
comparison |
The object to be compared with the |
transform |
A character vector containing any transformations that have been performed on the objects prior to this comparison. |
equal |
Whether to test for equality if the test for identity fails. |
colsOnly |
Whether to only drop extra columns (not rows) when comparing data frames. |
ignoreColOrder |
For data frames, whether to reorder columns by name first. |
ignoreNameCase |
For data frames and lists, whether to ignore the case of names when reordering components by name. |
... |
Arguments passed to |
Details
This function checks whether the two objects being compared are
of the same size and, if they are not, it shrinks the larger one.
Then the two objects are compared using compareIdentical()
and, if that fails and equal=TRUE
, using compareEqual()
.
This function is generic, with specific methods for arrays, matrices, tables, and data frames.
For vectors, extra elements are dropped from the longer object.
For data frames, extra columns, (and, if
colsOnly=FALSE
, extra rows) are dropped. For lists,
extra components are dropped. For arrays, extra dimensions are
dropped. For matrices, the comparison
is forced to be
two-dimensional. For tables, extra dimensions are collapsed
(using sum()
).
Value
An object of class "comparison"
.
Use isTRUE()
to determine whether the
comparison has succeeded.
Author(s)
Paul Murrell
See Also
compare
and
compareEqual
Examples
compareShorten(1:5, 1:10)
compareShorten(matrix(1:10, ncol=2),
array(1:100, dim=c(5, 2, 10)))