Learn R Programming

hyperSpec (version 0.95)

orderwl: Sorting the Wavelengths of a hyperSpec Object

Description

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

Usage

orderwl(x, na.last = TRUE, decreasing = FALSE,
        short = "orderwl", date = NULL, user = NULL)

Arguments

x
The hyperSpec object.
na.last, decreasing
Handed to order.
short, date, user
Handed to logentry.

Value

  • A hyperSpec object.

Details

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

See Also

order

Examples

Run this code
## 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")
plot (orderwl (spc), "spc", add = TRUE, col = "red")

## 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[[]]

spc <- orderwl (spc)
lines (seq_len(nwl(spc)), spc[[]], type = "l", col = "red")
lines (seq_len(nwl(spc)) / 2 + 0.5, spc[[]], type = "l", col = "blue")
spc[[]]

Run the code above in your browser using DataLab