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

idsR Documentation

Retrieves or sets the ids 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. 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

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

  • ids(object, ..., as.vector = TRUE)

  • ids(object) <- value

Author(s)

Pierre Roudier pierre.roudier@gmail.com

Examples


# 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)


spectacles documentation built on July 10, 2023, 1:59 a.m.