Learn R Programming

prospectr

Functions for Chemometric Processing and Sample Selection of Spectroscopic Data

Last update: 2026-08-24

Version: 0.2.11 – postdetrendy

In science, one man’s noise is another man’s signal

About

prospectr provides tools for signal processing and chemometrics, with a focus on pre-processing and sample selection of spectral data. It is increasingly used in spectroscopic applications, as reflected by the growing number of scientific publications citing the package.

Although similar functions are available in other packages such as signal, many functions in prospectr are designed to work consistently with data.frame, matrix, and vector inputs. Several functions are optimised for speed and rely on C++ code through the Rcpp and RcppArmadillo packages.

Documentation

The package includes three vignettes covering all major functionality:

  1. An introduction to the prospectr package: Overview, installation, and how to cite the package.
  2. Signal processing: Pre-processing methods including smoothing, derivatives, scatter corrections, baseline removal, centering, scaling, resampling, and continuum removal.
  3. Selecting representative calibration samples: Algorithms for selecting representative calibration and validation subsets from spectral data.

Core functionality

Signal processing:

  • movav(): moving average filter
  • savitzkyGolay(): Savitzky-Golay smoothing and derivatives
  • gapDer(): gap-segment derivative
  • baseline(): baseline removal
  • continuumRemoval(): continuum-removed reflectance or absorbance
  • detrend(): SNV-Detrend normalisation
  • standardNormalVariate(): Standard Normal Variate (SNV) transformation
  • msc(): Multiplicative Scatter Correction
  • binning(): average a signal in column bins
  • resample(): resample a signal to new band positions
  • resample2(): resample a signal using FWHM values
  • blockScale(): block scaling
  • blockNorm(): sum of squares block weighting

Calibration sampling:

  • naes(): k-means sampling
  • kenStone(): Kennard-Stone (CADEX) algorithm
  • duplex(): DUPLEX algorithm
  • shenkWest(): SELECT algorithm
  • puchwein(): Puchwein sampling
  • honigs(): sample selection by spectral subtraction

Other utilities:

  • read_nircal(): read binary files from BUCHI NIRCal software
  • readASD(): read binary or ASCII files from ASD instruments
  • spliceCorrection(): correct for detector splice steps in ASD FieldSpec Pro
  • cochranTest(): detect replicate outliers with the Cochran C test

Installation

Install from CRAN:

install.packages("prospectr")

Or install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("l-ramirez-lopez/prospectr")

The package requires a C++ compiler. On Windows, install Rtools. On macOS, you may need to install gfortran and clang from CRAN tools.

Citing the package

citation(package = "prospectr")

Contributing

Contributions are welcome! Please read our Contributing Guidelines (available in the GitHub repo) before submitting pull requests.

This project follows a Code of Conduct available in the GitHub repo.

Bug reports

Report issues at GitHub or contact the maintainer (ramirez.lopez.leo@gmail.com).

Related packages

  • resemble: Memory-based learning and local modelling for spectral chemometrics.

Copy Link

Version

Install

install.packages('prospectr')

Monthly Downloads

1,503

Version

0.2.11

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Leonardo RamirezLopez

Last Published

August 25th, 2026

Functions in prospectr (0.2.11)

detrend

Detrending spectral data
duplex

DUPLEX algorithm for calibration sampling
get_msc_coeff

get_msc_coeff
naes

k-means sampling
kenStone

Kennard-Stone algorithm for calibration sampling
get_nircal_metadata

get the metadata of the samples in the nircal file
pkg_info

Get the package version info
fastDist

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

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

get the response variables in the nircal file
get_nircal_spectra

get the spectra in the nircal file
readASD

Read ASD FieldSpec Pro binary and ASCII files
standardNormalVariate

Standard normal variate transformation
puchwein

Puchwein algorithm for calibration sampling
prospectr-package

Overview of the functions in the prospectr package
sqrtSm

Square root of (square) symetric matrices
savitzkyGolay

Savitzky-Golay smoothing and differentiation
resample_fwhm

Resample to given band position and fwhm
read_nircal

Import BUCHI NIRCal files
resample

Resample spectral data
resample2

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

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

SELECT algorithm for calibration sampling
continuumRemoval

Continuum Removal
blockScale

Hard or soft block scaling
cochranTest

Cochran C Test
convCppM

Convolve
baseline

baseline
binning

Signal binning
fastDistV

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

get the number of spectral variables in the nircaa file
Cul

Cochran C critical value
gapDer

Gap-Segment derivative
movav

Moving average
bitAND

bitwise operations
get_nircal_description

get the description of the spectra in the nircal file
msc

Multiplicative Scatter Correction (msc)
get_nircal_indices

get the positions of relevant data witihi the nircal file
NIRsoil

NIRSoil
get_nircal_comments

get the comments of the spectra in the nircal file
blockNorm

Sum of squares block weighting
honigs

Honigs algorithm for calibration sampling