spectacles (version 0.5-0)

wl: Retrieves or sets the wavelengths of a Spectra* object.

Description

Either retrieves the wavelengths from a Spectra* object, or creates a Spectra* object from a "data.frame" object by setting some of its columns as the wavelengths.

When applied to a Spectra* object, this functions simply returns the wavelengths of the spectra it is storing.

If applied on a "data.frame" object, it is an helper function to create a Spectra* object. It then needs to be indicated the wavelengths at which the spectra values are measured. The assumption is that each row of the "data.frame" is a spectra, and the column names of the "data.frame" contain the wavelengths values.

If all the columns are used to create the Spectra* object, a Spectra object is created. If some attributes are left, they will be used to generate a SpectraDataFrame object.

Usage

# S4 method for Spectra
wl(object)

# S4 method for data.frame wl(object) <- value

# S4 method for Spectra wl(object) <- value

Arguments

object

a "data.frame" or an object inheriting from class Spectra

value

the wavelengths of the Spectra* object to create

...

Ignored

Value

If applied on a "data.frame", either a Spectra or a SpectraDataFrame object. If applied on a Spectra* object, a vector.

See Also

spectra, Spectra-class, SpectraDataFrame-class

Examples

Run this code
# NOT RUN {
# Loading example data
data(oz)
spectra(oz) <- sr_no ~ ... ~ 350:2500

# Retrieving wavelengths from Spectra* object
wl(oz)

# Replacing wavelength values - USE WITH CAUTION!
wl(oz) <- 1:length(oz)
wl(oz)

# Use to initiate a Spectra* object from a data.frame
data(oz)
wl(oz) <- 350:2500
ids(oz) <- ~ sr_no

# }

Run the code above in your browser using DataLab