hy2mat

hy2mat(sp)

Arguments

sp

Spectroscopic data (either a hyperSpec object or a matrix).

Value

Either a matrix or an error, if it's impossible to extract a matrix.

Author

Vilmantas Gegzna

Examples


data(flu, package = "hyperSpec")

flu
#> hyperSpec object
#>    6 spectra
#>    3 data columns
#>    181 data points / spectrum
a <- hy2mat(flu)
b <- hy2mat(flu$spc)
#> Error in switch(class(sp), hyperSpec = sp$spc, matrix = sp, stop("The class of the input must be either \"hyperSpec\" or \"matrix\"")): EXPR must be a length 1 vector

identical(a,b)
#> Error in identical(a, b): object 'b' not found
## [1] TRUE


hy2mat(matrix(NA,5,10))
#> Error in switch(class(sp), hyperSpec = sp$spc, matrix = sp, stop("The class of the input must be either \"hyperSpec\" or \"matrix\"")): EXPR must be a length 1 vector