Learn R Programming

spectacles (version 0.5-2-2)

SpectraDataFrame: Constructor for the SpectraDataFrame class.

Description

Constructor for the SpectraDataFrame class. Creates a SpectraDataFrame object, either from scratch, or from an existing Spectra object.

Usage

SpectraDataFrame(..., wl = numeric(), nir = matrix(),
  id = as.character(NA), units = "nm", data = data.frame())

Arguments

...

an object inheriting from "Spectra"

wl

a numeric vector giving the wavelengths at with the spectra have been measured

nir

a "matrix" or a "data.frame" object giving the spectra values for each sample

id

a vector giving the unique id of each sample in the collection

units

a character giving the unit in which the wavelengths values are expressed

data

object of class "data.frame" containing the attribute data

Value

a new "SpectraDataFrame" object

See Also

spectra, wl, Spectra-class

Examples

Run this code
# NOT RUN {
  # Creating a SpectraDataFrame object from scratch
  my.wl <- 350:2500
  my.id <- c("A", "B")
  my.nir <- matrix(runif(2*length(my.wl)), nrow=2)
  my.data <- data.frame(foo = runif(2), bar = LETTERS[1:2])
  my.sdf <- SpectraDataFrame(wl = my.wl, nir = my.nir, id = my.id, data = my.data)

  # Creating a SpectraDataFrame object from an existing Spectra object
  my.s <- Spectra(wl = my.wl, nir = my.nir, id = my.id)
  my.sdf <- SpectraDataFrame(my.s, data = my.data)

# }

Run the code above in your browser using DataLab