These functions are shortcuts to convert other objects into hypeSpec objects.

as.hyperSpec(X, ...)

# S4 method for matrix
as.hyperSpec(X, wl = NULL, ...)

# S4 method for data.frame
as.hyperSpec(X, spc = NULL, wl = NULL, labels = attr(X, "labels"), ...)

# S4 method for hyperSpec
as.hyperSpec(X)

Arguments

X

the object to convert. If X is:

  • a matrix, it is assumed to contain the spectra matrix,

  • a data.frame, it is assumed to contain extra data.

...

additional parameters that should be handed over to new("hyperSpec") (initialize).

wl

wavelength vector. Defaults to guessing from the column names in X.

spc

spectra matrix.

labels

list with labels.

Value

hyperSpec object

Note

Note that the behavior of as.hyperSpec(X) was changed when X is a data.frame: it now assumes X to be extra data, and returns a hyperSpec object with 0 wavelengths. To get the old behavior, use as.hyperSpec(as.matrix(X)).

See also

Examples

tmp <- data.frame(flu[[, , 400 ~ 410]])
(wl <- colnames(tmp))
#>  [1] "X405"   "X405.5" "X406"   "X406.5" "X407"   "X407.5" "X408"   "X408.5"
#>  [9] "X409"   "X409.5" "X410"  
extract_numbers(wl)
#>  [1] 405.0 405.5 406.0 406.5 407.0 407.5 408.0 408.5 409.0 409.5 410.0