spct_wide2long: Convert spectrum from wide to long form

View source: R/spct-wide2long.r

spct_wide2longR Documentation

Convert spectrum from wide to long form

Description

Convert spectrum from wide to long form

Usage

spct_wide2long(
  spct,
  fixed.cols = "w.length",
  idfactor = "spct.idx",
  rm.spct.class = FALSE,
  ...
)

Arguments

spct

An object with spectral data.

fixed.cols

character Names of variables that should be copied unchanged for each spectrum.

idfactor

character The name of the factor to be added to the long-form object and used to store the original name of the columns as an index to the different spectra.

rm.spct.class

logical If true the returned object is a data frame.

...

Currently ignored.

Details

Only objects of classes raw_spct, cps_spct, and object_spct normally contain multiple columns of spectral data. These are supported as well as generic_spct. Is the wide spectra contain multiple spectra in long form, the original idfactor is preserved.

Spectra that are already in long form, if passed as argument, are returned unchanged.

Because the classes defined for spectra have a well defined format, and known column names we can define a rather simple function for this operation.

Value

An object of the same class as spct or a data.frame with derived classes removed.

Examples


spct_wide2long(white_led.raw_spct)
spct_wide2long(white_led.cps_spct)
spct_wide2long(Ler_leaf.spct)


photobiology documentation built on Oct. 21, 2023, 1:06 a.m.