Class and Methods for Spectral Data

Input/Output, processing and visualization of spectra taken with different spectrometers, including SVC (Spectra Vista), ASD and PSR (Spectral Evolution). Implements an S3 class 'spectra' that other packages can build on. Provides methods to access, plot, manipulate, splice sensor overlap, vector normalize and smooth spectra.

Build Status Coverage Status CRAN Status

We are planning a major and exciting overhaul of spectrolab, but the planned improvments will probably break backwards compatibility! Please use the package to provide us with feedback, but do not rely heavily on our API just yet.

The package is being actively developed and parts of the API may still change. You’re welcome to give it a spin, but do so at your own risk. With that said, most parts of the package are pretty stable. Let us know if you find otherwise.


You can install spectrolab from CRAN using:


Using spectrolab

This vignette introduces spectrolab, and walks you through the basics of the package.

This vignette shows how to splice sensors using the function match_sensors and explains the details about how its arguments work. A more general processing vignette is coming soon.


In an effort to keep things tidy and in running order, direct commits to master are discouraged. The master branch of the "meireles/spectrolab" fork is protected.

I also use a pre-commit hook in my local repo that prevents me from breaking my own policy! I suggest you do the same.

We highly encourage you to read the vignette on advanced spectrolab use if you're planning on contributing to or developing a package that depends on spectrolab.


spectrolab 0.0.8 (2018-10-28)


  • switched to usethis::use_package from devtools deprecated version
  • generic "smooth" function has its own interface and the default now calls stats::smooth internally. Work in progress.

spectrolab 0.0.7 (2018-07-24)


  • Fixed major bug. Spectrum replacement (e.g. spec_a[i, ] = spec_b[1, ]) only replaced the reflectance and not the other information (names, metadata, etc.)


  • quantile now allows the user to choose names for the spectra

spectrolab 0.0.6 (2018-06-19)


  • NOT backwards compatible!. Now, as.spectra() does not assume by default that the first column of a matrix or data.frame contains the names for the spectra. Users must explicitly use the name_idx argument to pick the correct column
  • NOT backwards compatible!. enforce01 functions and attribute deprecated.


  • fixed bug in subset_by, where n_min was matching sample names instead of indices.

spectrolab 0.0.5 (2018-05-31)


  • Fixed bug in "reflectance" setter, where the object was not being returned
  • The parser inside read_spectra now finds the spectral data using tags instead of assuming that the data starts at a specific line


  • added unit tests for the read_spectra function
  • cleaned up several minor issues

spectrolab 0.0.4 (2017-12-13)


  • sample names in the spectra class are now required to be char. Names coercible to numeric will have a prefix added to them by default. This may break existing code!


  • updated README
  • refactored the internal i_is_index function
  • added unit tests for i_is_index function

spectrolab 0.0.3 (2017-11-15)


  • fixed index duplication in the match sensor vignette.
  • added CRAN installation instructions to
  • internal spline smoothing now requires the parallel package

spectrolab 0.0.2 (2017-09-14)

  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.0.15 by Jose Eduardo Meireles, 7 days ago

Browse source code at

Authors: Jose Eduardo Meireles [aut, cre] , Anna K. Schweiger [aut] , Jeannine Cavender-Bares [aut]

Documentation:   PDF Manual  

GPL-3 license

Imports grDevices, parallel, RColorBrewer, shiny, shinyjs

Depends on stats

Suggests covr, tinytex, knitr, rmarkdown, testthat

See at CRAN