features: Retrieves or sets the data slot of a SpectraDataFrame object.

featuresR Documentation

Retrieves or sets the data slot of a SpectraDataFrame object.

Description

Either retrieves the attributes values from the data slot of a SpectraDataFrame object, or upgrades a Spectra object to a SpectraDataFrame object by initialising its data slot by a suitable "data.frame" object.

Usage

## S4 method for signature 'SpectraDataFrame'
features(object,exclude_id)
## S4 replacement method for signature 'Spectra'
features(object,safe,exclude_id,key,append) <- value

Arguments

object

a Spectra object

exclude_id

see below

value

see below

safe

see below

key

see below

append

see below

Value

The features methods return a data.frame object, while the "features<-" methods return a SpectraDataFrame object.

Methods

x=Spectra

features(object, safe=TRUE, key=NULL, exclude_id=TRUE) <- value

object A Spectra object
safe Logical. If TRUE, data is being added to the object using a SQL join (using a key field given by the key option), otherwise it is assumed the order of the rows is consitent with the order of the rows in object
key Character, name of the column of the data.frame storing the ids for the SQL join. Ignored if safe is FALSE.
exclude_id Logical, if TRUE, ids used for the SQL join are removed from the data slot after the join.

x=SpectraDataFrame

features(obj, exclude_id=TRUE)

features(obj, safe=TRUE, key=NULL, exclude_id=TRUE, append=TRUE) <- value

object A SpectraDataFrame object
safe Logical. If TRUE, data is being added to the object using a SQL join (using a key field given by the key option), otherwise it is assumed the order of the rows is consitent with the order of the rows in object
key Character, name of the column of the data.frame storing the ids for the SQL join. Ignored if safe is FALSE.
exclude_id Logical. For the features method, if TRUE, the spectra ids are added to the data.frame that is returned. For the "features<-" method, If TRUE, ids used for the SQL join are removed from the data slot after the join.
append Logical, if TRUE, the data is appended to any existing data. if FALSE, the data provided is erasing any existing data.

Author(s)

Pierre Roudier pierre.roudier@gmail.com

See Also

spectra, wl, SpectraDataFrame-class

Examples


# Loading example data
data(oz)
spectra(oz) <- sr_no ~ ... ~ 350:2500

# Printing available data
features(oz)

# Promoting a Spectra to a SpectraDataFrame object
s <- as(oz, "Spectra")

# Generating dummy data
d <- data.frame(
  id = ids(oz), 
  foo = runif(nrow(oz)), 
  bar = sample(LETTERS[1:5], size = nrow(oz), replace = TRUE)
)
head(d)

# Affecting data to Spectra object
features(s) <- d
features(s)

# Adding data to an existing SpectraDataFrame object

features(oz) <- d
features(oz)


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