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

Description Usage Arguments Value Methods Author(s) 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. 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).

Usage

1
2
3
4
5
6
7
8
ids(object, ...)
ids(object) <- value

## S4 replacement method for signature 'Spectra'
ids(object) <- value

## S4 replacement method for signature 'SpectraDataFrame'
ids(object) <- value

Arguments

object

an object of class "Spectra" or inheriting from this class

...
as.vector

Controls whether the IDs are returned as a vector or as a data.frame (defaults to TRUE)

value

character vector for new IDs

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

Author(s)

Pierre Roudier pierre.roudier@gmail.com

Examples

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

# Retrieving ids
ids(oz)

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

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

pierreroudier/inspectr documentation built on May 25, 2019, 6:08 a.m.