The comparison operators >, <, >=, <=, ==, and != for hyperSpec objects.

all.equal() checks the equality of two hyperSpec objects.

The comparison operators >, <, >=, <=, ==, and != work on the spectra matrix of the hyperSpec object. They have their usual meaning (see base::Comparison()). The operators work also with one hyperSpec object and a numeric (scalar) object or a matrices of the same size as the spectra matrix of the hyperSpec object.

With numeric vectors sweep() might be more appropriate.

If you want to calculate on the data.frame hyperSpec@data, you have to do this directly on hyperSpec@data.

# S4 method for hyperSpec,hyperSpec
Compare(e1, e2)

# S4 method for hyperSpec,numeric
Compare(e1, e2)

# S4 method for hyperSpec,matrix
Compare(e1, e2)

# S4 method for numeric,hyperSpec
Compare(e1, e2)

# S4 method for matrix,hyperSpec
Compare(e1, e2)

# S4 method for hyperSpec,hyperSpec
all.equal(
  target,
  current,
  ...,
  check.attributes = FALSE,
  check.names = FALSE,
  check.column.order = FALSE,
  check.label = FALSE,
  tolerance = hy_get_option("tolerance"),
  wl.tolerance = hy_get_option("wl.tolerance")
)

Arguments

e1, e2

Either two hyperSpec objects or one hyperSpec object and matrix of same size as hyperSpec[[]] or a scalar (numeric of length 1).

As hyperSpec objects must have numeric spectra matrices, the resulting matrix of the comparison is returned directly.

target, current

two hyperSpec objects that are tested for equality.

...

handed to base::all.equal() when testing the slots of the hyperSpec objects

check.attributes, check.names

see base::all.equal()

check.column.order

If two objects have the same data, but the order of the columns (determined by the names) differs, should they be regarded as different?

check.label

Should the slot label be checked?
If the labels differ only in the order of their entries, they are considered equal.

tolerance, wl.tolerance

tolerances for checking wavelengths and data, respectively

Value

A logical matrix for the comparison operators. all.equal returns either TRUE, or a character vector describing the differences. In conditions, the result must therefore be tested with base::isTRUE().

See also

  • sweep-methods() for calculations involving a vector and the spectral matrix.

  • methods::S4groupGeneric() for group generic methods.

  • base::Comparison() for the base comparison functions.

  • Arith() for arithmetic operators,

  • Math() for mathematical group generic functions (groups Math and Math2) working on hyperSpec objects.

base::all.equal() and base::isTRUE()

Author

C. Beleites

Examples


flu[, , 445 ~ 450] > 300
#>        445 445.5   446 446.5   447 447.5   448 448.5   449 449.5   450
#> [1,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [3,]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#> [4,]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#> [5,]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#> [6,]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE

all(flu == flu[[]])
#> [1] TRUE