movav {prospectr}R Documentation

Moving average

Description

A simple moving average of a vector, data.frame or matrix using a convolution function written in C++/Rcpp for fast computing

Usage

movav(X,w)

Arguments

X

numeric data.frame, matrix or vector to process

w

filter length

Value

a matrix or vector with the filtered signal(s)

Author(s)

Antoine Stevens

See Also

sgolayfilt, savitzkyGolay, gapDer, binning, continuumRemoval

Examples

data(NIRsoil)
wav <- as.numeric(colnames(NIRsoil$spc))
spc <- 1/10^NIRsoil$spc # conversion to reflectance
spc <- spc + rnorm(length(spc),0,0.001) # adding some noise
matplot(wav,t(spc[1:10,]),type='l',xlab='Wavelength /nm',ylab='Reflectance')
mov <- movav(spc,w=11) # window size of 11 bands
matlines(as.numeric(colnames(mov)),t(mov[1:10,])) # smoothed data

[Package prospectr version 0.1.3 Index]