hyperSpec objectR/DEPRECATED-wl_sort.R
DEPRECATED-orderwl.RdThese hyperSpec functions are deprecated and not maintained any more. You should not use these. Currently they are present due to back-compatibility reasons and will be removed in the next release of the package. Please, use the suggested alternative functions instead.
_____________
Rearranges the hyperSpec object so that the wavelength vector is in
increasing (or decreasing) order.
The wavelength vector is sorted and the columns of the spectra matrix are rearranged accordingly.
orderwl(x, na.last = TRUE, decreasing = FALSE)The hyperSpec object.
Handed to base::order().
A hyperSpec object.
## Example 1: different drawing order in plot_spc
spc <- new("hyperSpec", spc = matrix(rnorm(5) + 1:5, ncol = 5))
spc <- cbind(spc, spc + .5)
plot_spc(spc)
text(wl(spc), spc[[]], as.character(1:10), col = "darkred")
spc_sorted <- orderwl(spc)
#> Warning: Function 'orderwl' is deprecated.
#> Use function 'wl_sort' instead.
plot_spc(spc_sorted)
text(wl(spc_sorted), spc_sorted[[]], as.character(1:10), col = "darkred")
## Example 2
spc <- new("hyperSpec", spc = matrix(rnorm(5) * 2 + 1:5, ncol = 5))
spc <- cbind(spc, spc)
plot(seq_len(nwl(spc)), spc[[]], type = "b")
spc[[]]
#> 1 2 3 4 5 1 2 3
#> [1,] 1.283441 -0.5075538 2.064181 4.539015 1.31807 1.283441 -0.5075538 2.064181
#> 4 5
#> [1,] 4.539015 1.31807
spc_sorted <- orderwl(spc)
#> Warning: Function 'orderwl' is deprecated.
#> Use function 'wl_sort' instead.
lines(seq_len(nwl(spc_sorted)), spc_sorted[[]], type = "l", col = "red")
spc_sorted[[]]
#> 1 1 2 2 3 3 4
#> [1,] 1.283441 1.283441 -0.5075538 -0.5075538 2.064181 2.064181 4.539015
#> 4 5 5
#> [1,] 4.539015 1.31807 1.31807