ids: Retrieves or sets the ids of a 'Spectra*' object.

Description Details Value Methods Author(s) See Also Examples

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.

Details

The "ids<-" method for SpectraDataFrame objects allows to use a formula interface to use a column in its data slot as the object IDs (see the last example provided in the Examples section).

Value

The ids methods return a vector if as.vector is TRUE, a data.frame otherwise. The "ids<-" method return a SpectraDataFrame object (or a Spectra object if the column in the data slot that has been used to initiate the IDs was the only attribute).

Methods

ids(obj, ..., as.vector = TRUE)

ids(obj) <- value

obj A Spectra object
... Ignored
as.vector Logical, returns the IDs as a character vector rather than a 1-column data.frame.
value Either a formula or a vector of new IDs (see the Details section).

Author(s)

Pierre Roudier [email protected]

See Also

spectra, Spectra-class, SpectraDataFrame-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Loading example data
data(australia)
spectra(australia) <- sr_no ~ ... ~ 350:2500

# Retrieving ids
ids(australia)

# Setting ids using a vector of values
ids(australia) <- seq_len(nrow(australia))
ids(australia)

# Setting ids using an attribute
australia$new_id <- seq_len(nrow(australia)) + 1000
ids(australia) <- ~ new_id
ids(australia)

inspectr documentation built on May 2, 2019, 5:45 p.m.