Learn R Programming

prospectr

Antoine Stevens & Leo Ramirez-Lopez

Last update: 2025-03-05

Version: 0.2.8 – galo

prospectr is becoming more and more used in spectroscopic applications, which is evidenced by the number of scientific publications citing the package. This package is very useful for signal processing and chemometrics in general as it provides various utilities for pre–processing and sample selection of spectral data. While similar functions are available in other packages, like signal, the functions in this package works indifferently for data.frame, matrix and vector inputs. Besides, several functions are optimized for speed and use C++ code through the Rcpp and RcppArmadillo packages.

Installing it from GitHub

Install this package from github by:

remotes::install_github("l-ramirez-lopez/prospectr")

NOTE: in some MAC Os it is still recommended to install gfortran and clang from here. Even for R >= 4.0. For more info, check this issue.

News

Check the NEWS document for new functionality and general changes in the package.

Vignette

A vignette for prospectr explaining its core functionality is available at https://CRAN.R-project.org/package=prospectr/vignettes/prospectr.html.

Core functionality

A vignette gives an overview of the main functions of the package. Just type vignette("prospectr-intro") in the console to access it. Currently, the following preprocessing functions are available:

  • resample() : resample a signal to new coordinates by linear or spline interpolation

  • resample2() : resample a signal to new coordinates using FWHM values

  • movav() : moving average

  • standardNormalVariate() : standard normal variate

  • msc() : multiplicative scatter correction

  • detrend() : detrend normalization

  • baseline() : baseline removal/correction

  • blockScale() : block scaling

  • blockNorm() : sum of squares block weighting

  • binning() : average in column–wise subsets

  • savitzkyGolay() : Savitzky-Golay filter (smoothing and derivatives)

  • gapDer() : gap-segment derivative

  • continuumRemoval() : continuum-removed absorbance or reflectance values

The selection of representative samples/observations for calibration of spectral models can be achieved with one of the following functions:

  • naes() : k-means sampling

  • kenStone() : CADEX (Kennard–Stone) algorithm

  • duplex() : DUPLEX algorithm

  • shenkWest() : SELECT algorithm

  • puchwein() : Puchwein sampling

  • honigs() : Unique-sample selection by spectral subtraction

Other useful functions are also available:

  • read_nircal() : read binary files exported from BUCHI NIRCal software

  • readASD() : read binary or text files from an ASD instrument (Indico Pro format)

  • spliceCorrection() : correct spectra for steps at the splice of detectors in an ASD FieldSpec Pro

  • cochranTest() : detects replicate outliers with the Cochran C test

Citing the package

Antoine Stevens and Leornardo Ramirez-Lopez (2025). An introduction to the prospectr package. R package Vignette R package version 0.2.8. A BibTeX entry for LaTeX users is:

 @Manual{stevens2022prospectr,
    title = {An introduction to the prospectr package},
    author = {Antoine Stevens and Leornardo Ramirez-Lopez},
    publication = {R package Vignette},
    year = {2025},
    note = {R package version 0.2.8},
  }

Bug report and development version

You can send an email to the package maintainer (ramirez.lopez.leo@gmail.com) or create an issue on github. To install the development version of prospectr, simply install devtools from CRAN then run install_github("l-ramirez-lopez/prospectr").

Copy Link

Version

Install

install.packages('prospectr')

Monthly Downloads

1,133

Version

0.2.8

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Leonardo RamirezLopez

Last Published

March 5th, 2025

Functions in prospectr (0.2.8)

kenStone

Kennard-Stone algorithm for calibration sampling
honigs

Honigs algorithm for calibration sampling
get_nircal_lengthspc

get the number of spectral variables in the nircaa file
blockScale

Hard or soft block scaling
cochranTest

Cochran C Test
e2m

A function for transforming a matrix from its Euclidean space to its Mahalanobis space
naes

k-means sampling
pkg_info

Get the package version info
spliceCorrection

Splice correction of a spectral matrix acquired with an ASD spectrometer
shenkWest

SELECT algorithm for calibration sampling
fastDist

A fast distance algorithm for two matrices written in C++
detrend

Detrending spectral data
get_nircal_metadata

get the metadata of the samples in the nircal file
prospectr-package

Overview of the functions in the prospectr package
puchwein

Puchwein algorithm for calibration sampling
get_nircal_indices

get the positions of relevant data witihi the nircal file
get_nircal_description

get the description of the spectra in the nircal file
NIRsoil

NIRSoil
duplex

DUPLEX algorithm for calibration sampling
movav

Moving average
read_nircal

Import BUCHI NIRCal files
readASD

Read ASD FieldSpec Pro binary and ASCII files
get_nircal_response

get the response variables in the nircal file
msc

Multiplicative Scatter Correction (msc)
get_nircal_spectra

get the spectra in the nircal file
resample

Resample spectral data
savitzkyGolay

Savitzky-Golay smoothing and differentiation
resample2

Resample a high resolution signal to a low resolution signal using full width half maximum (FWHM) values
resample_fwhm

Resample to given band position and fwhm
sqrtSm

Square root of (square) symetric matrices
standardNormalVariate

Standard normal variate transformation
convCppM

Convolve
binning

Signal binning
baseline

baseline
continuumRemoval

Continuum Removal
blockNorm

Sum of squares block weighting
gapDer

Gap-Segment derivative
get_msc_coeff

get_msc_coeff
fastDistV

A fast distance algorithm for a matrix and a vector written in C++
Cul

Cochran C critical value
bitAND

bitwise operations
get_nircal_comments

get the comments of the spectra in the nircal file