Rearranges the hyperSpec object so that the wavelength vector is in increasing (or decreasing) order.

orderwl(x, na.last = TRUE, decreasing = FALSE)

Arguments

x

The hyperSpec object.

na.last, decreasing

Handed to base::order().

Value

A hyperSpec object.

Details

The wavelength vector is sorted and the columns of the spectra matrix are rearranged accordingly.

See also

Author

C. Beleites

Examples

## Example 1: different drawing order in plotspc 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))
spc <- orderwl(spc) plot(spc, "spc")
text(wl(spc), spc[[]], as.character(1:10))
## 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,] 0.6526606 3.209341 3.136269 2.110489 6.626358 0.6526606 3.209341 3.136269 #> 4 5 #> [1,] 2.110489 6.626358
spc <- orderwl(spc) lines(seq_len(nwl(spc)), spc[[]], type = "l", col = "red")
spc[[]]
#> 1 1 2 2 3 3 4 4 #> [1,] 0.6526606 0.6526606 3.209341 3.209341 3.136269 3.136269 2.110489 2.110489 #> 5 5 #> [1,] 6.626358 6.626358