Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handling and analysis of Vis-NIR spectra in R

NotificationsYou must be signed in to change notification settings

pierreroudier/spectacles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRAN_Status_BadgeTotal_Downloads

Welcome to the spectacles project page

Scope of the Package

Thespectacles package is making it easy (or at leasteasier!) to handle spectroscopy data. It provides the user with dedicated classes (namelySpectra andSpectraDataFrame), 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 ofspectacles is on CRAN (:tada:):

install.packages('spectacles')

You can also install the development version using thedevtools 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 egggplot2 orlattice

It also gives overloads to the most common operators such as$,[, or[[, so that any user familiar withdata.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 inspectacles, such as the ASD splice correction.

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

# Example of splice correction, followed by# a first derivative, followed by a SNVmy_spectra %>%   splice %>%   apply_spectra(diff, 1) %>%  apply_spectra(snv)  # Another example using prospectrmy_spectra %>%   splice %>%   apply_spectra(prospectr::continuumRemoval, wav = wl(.)) %>%   plot

Regression and Classification

Again, lots of existing methods available, sospectacles is not re-implementing any of these. There's various ways to usespectacles with the different methods available, but my favoured option is to use it in conjonction with thecaret 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 likeinspectr?!?

Yes, I once had a package calledinspectr on Github, andspectacles is very much the continuation ofinspectr. The only reason whyinspectr changed name is that someone pushed a package calledinspectr on CRAN (despiteinspectr being quite visible on Github.... :-/). So, lesson learnt this time!

About

Handling and analysis of Vis-NIR spectra in R

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp