If operands are matrices, they are completed and sorted relative to one another prior to comparison.

equal_byname(...)

Arguments

...

operands to be compared

Value

TRUE iff all information is equal, including row and column types and row and column names and entries in the matrices.

Details

Comparisons are made by isTRUE(all.equal(a, b)) so that variations among numbers within the computational precision will still return TRUE.

If EXACT comparison is needed, use identical_byname, which compares using identical(a, b).

Examples

a <- matrix(1:4, nrow = 2) b <- matrix(1:4, nrow = 2) equal_byname(a, b)
#> [1] TRUE
equal_byname(a, b + 1e-100)
#> [1] TRUE
identical_byname(a, b + 1e-100)
#> [1] FALSE
a <- a %>% setrowtype("Industries") %>% setcoltype("Commodities") equal_byname(a, b) # FALSE because a has row and column types, but b does not.
#> [1] FALSE
b <- b %>% setrowtype("Industries") %>% setcoltype("Commodities") equal_byname(a, b)
#> [1] TRUE
dimnames(a) <- list(c("i1", "i2"), c("c1", "c2")) dimnames(b) <- list(c("c1", "c2"), c("i1", "i2")) equal_byname(a, b) # FALSE, because row and column names are not equal
#> [1] FALSE
dimnames(b) <- dimnames(a) equal_byname(a, b)
#> [1] TRUE