Learn R Programming

photobiology (version 0.11.4)

spct_wide2long: 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,
  ...
)

Value

An object of the same class as spct or a data.frame

with derived classes removed.

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.

Examples

Run this code

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

Run the code above in your browser using DataLab