Convenience function to normalize spectroscopic data in a hyperSpec object.

sp_normalize2(sp, norm = "max", in_range = min ~ max, at = NULL)

Arguments

sp

hyperSpec object.

norm

("max" | "mean" | "area" | "area_abs" | "nim")
a way of normalization.

in_range, at

(numeric | formula)
either a single numeric value or a pair of values describing the range (e.g., 300~350) of wavelengths to be used for normalization. Default is range = min~max.

Value

sp with normalized spectra in (sp@data$spc).

Examples


library(magrittr)

Spectra2 <- hyperSpec::chondro
#> Error: 'chondro' is not an exported object from 'namespace:hyperSpec'
Spectra2 %>% plotspc()
#> Warning: Function 'plotspc' is deprecated. 
#> Use function 'plot_spc' instead.


Spectra2 %>% hyperSpec::normalize01() %>% plotspc()
#> Warning: Function 'plotspc' is deprecated. 
#> Use function 'plot_spc' instead.
#> Warning: Function 'normalize01' is deprecated. 
#> Use function 'normalize_01' instead.


Spectra2 %>% sp_normalize2(at = 700) %>% plotspc()
#> Warning: Function 'plotspc' is deprecated. 
#> Use function 'plot_spc' instead.


Spectra2 %>% sp_normalize2("area") %>% plotspc()
#> Warning: Function 'plotspc' is deprecated. 
#> Use function 'plot_spc' instead.


Spectra2 %>% sp_normalize2("area", in_range = 1400~1700) %>% plotspc()
#> Warning: Function 'plotspc' is deprecated. 
#> Use function 'plot_spc' instead.
#> Error in .apply_workhorse(X@data, MARGIN = MARGIN, FUN = FUN, ...): empty spectra matrix.