MyNixOS website logo
Description

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.

CRAN_Status_Badge Total_Downloads

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

The stable version of spectacles is on CRAN (:tada:):

install.packages('spectacles')

You can also install the development 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!

Metadata

Version

0.5-4

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows