spectacles v0.5-0

0

Monthly downloads

0th

Percentile

Storing, Manipulating and Analysis Spectroscopy and Associated Data

Stores and eases the manipulation of spectra and associated data, with dedicated classes for spatial and soil-related data.

Readme

Travis-CI Build Status CRAN_Status_Badge

Welcome to the spectacles project page

Scope of the Package

The spectacles package is making it easy (or at least easier!) to handle spectroscopy data. It provides the user with dedicated classes (namely Spectra and SpectraDataFrame), so that most of the useful information about the spectral dataset is available in one R object:

  • the spectral values
  • the wavelengths at which these have been recorded
  • some kind of ID
  • if available, some associated data (typically, some lab measurements)

Installation

spectacles is not on CRAN (yet?), but you can install the latest version using the devtools package:

# Install devtools if you don't have it on your machine
# install.packages('devtools')
devtools::install_github("pierreroudier/spectacles")

Graphical Capabilities

It also provides easy ways to plot a collection of spectra:

  • simple line plots of the individual spectra
  • offset plots of the individual spectra
  • stacked plots of the individual spectra
  • summary plots of a whole collection, or aggregated against a given factor
  • tools to code more advanced visualisations yourself using eg ggplot2 or lattice

It also gives overloads to the most common operators such as $, [, or [[, so that any user familiar with data.frame object would fell right at home.

Processing

The philosophy of the package is really just to make it easier to work with quite complex data. There are a lot of tools already existing in R to do spectral preprocessing (signal, etc.). A few additional tools have been added in spectacles, such as the ASD splice correction.

The idea is for the package to work quite well with the pipe (%>%) operator from the magrittr package, to create chains of pre-processing operators. The function apply_spectra makes it easy to work with any function whose input is either a numeric vector or a matrix:

# Example of splice correction, followed by
# a first derivative, followed by a SNV

my_spectra %>% 
  splice %>% 
  apply_spectra(diff, 1) %>%
  apply_spectra(snv)

# Another example using prospectr
my_spectra %>% 
  splice %>% 
  apply_spectra(prospectr::continuumRemoval, wav = wl(.)) %>% 
  plot

Regression and Classification

Again, lots of existing methods available, so spectacles is not re-implementing any of these. There's various ways to use spectacles with the different methods available, but my favoured option is to use it in conjonction with the caret package, which gives a unique API to 160+ models in R:

fit <- train(
  y = s$carbon,
  x = spectra(s),
  method = "pls"
)
spectroSummary(fit)

Hey, that sounds a lot like inspectr?!?

Yes, I once had a package called inspectr on Github, and spectacles is very much the continuation of inspectr. The only reason why inspectr changed name is that someone pushed a package called inspectr on CRAN (despite inspectr being quite visible on Github.... :-/). So, lesson learnt this time!

Functions in spectacles

Name Description
base_line Baseline correction using the baseline package#'
Spectra-class Spectra* classes
continuum_removal Continuum removal
SpectraDataFrame Constructor for the SpectraDataFrame class.
apply_spectra Apply a function on the spectra of a Spectra* object
aggregate_spectra Aggregates spectral and data information
kenstone Kennard-Stone algorithm for optimal calibration set selection.
spectacles-package Storing, Manipulating and Analysis Spectroscopy and Associated Data in R
spectra-methods Retrieves or sets the spectra of a Spectra* objects.
Spectra Constructor for the Spectra class.
dimensions Retrieve dimensions of Spectra* objects
extraction-methods Extracting and replacing parts of Spectra* objects
plot_offset Offset plot of a collection of spectra
plot_stack Stacked plot of a collection of spectra
features Retrieves or sets the data slot of a SpectraDataFrame object.
fill_spectra Fill missing wavelengths of a Spectra* object with a given value
australia Australia spectra library data set
rbind Stacking Spectra objects together
res,numeric-method Spectral resolution
load_oz Load the australia dataset
melt_spectra Melts the spectra data of a Spectra object and returns it as wide format.
separate Separates a Spectra* object into a calibration and a validation set.
snv Standard and Robust Normal Variate transformations
wl Retrieves or sets the wavelengths of a Spectra* object.
wl_units Wavelengths of Spectra* objects
splice Splice correction of a spectra collected using ASD hardware
split Split a Spectra* object using factors
plot-Spectra Plots an object inheriting from the Spectra class
plot_summary Summary plot of a collection of spectra
postResampleSpectro Calculates performance indictors across resamples
subset Subset SpectraDataFrame object
summary Summary
cut Manipulating the wavelength range of a Spectra object
ids Retrieves or sets the ids of a Spectra* object.
mutate Mutate a Spectra* object by transforming the spectra values, and/or adding new or replacing existing attributes.
big.head Return the First or Last Part of an Object
No Results!

Last month downloads

Details

Type Package
Date 2017-12-21
URL https://github.com/pierreroudier/spectacles/
BugReports https://github.com/pierreroudier/spectacles/issues
License GPL-3
LazyData true
Collate 'spectacles-package.R' 'AAA-Classes.R' 'Spectra-methods.R' 'SpectraDataFrame-methods.R' 'ZZZ.R' 'aggregate_spectra.R' 'australia.R' 'big_head.R' 'kenstone.R' 'performance.R' 'plot-methods.R' 'preprocessing.R' 'setters.R' 'splice.R'
RoxygenNote 6.0.1
NeedsCompilation no
Packaged 2017-12-21 20:43:35 UTC; pierre
Repository CRAN
Date/Publication 2017-12-22 18:33:10 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/spectacles)](http://www.rdocumentation.org/packages/spectacles)