Learn R Programming

MALDIquant (version 1.8)

.movingAverage: Moving Average Smoothing Filter

Description

This function runs a simple 2-side moving average. It is hidden by NAMESPACE because it is a private function and smoothIntensity,MassSpectrum-method should be used instead.

Usage

.movingAverage(y, halfWindowSize=2)

Arguments

y
intensity values
halfWindowSize
half window size. The resulting window reaches from mass[currentIndex-halfWindowSize] to mass[currentIndex+halfWindowSize] (window size is 2*halfWindowSize+1).

Value

  • double, a smoothed intensity vector.

See Also

smoothIntensity,MassSpectrum-method, .savitzkyGolay, MassSpectrum

Examples

Run this code
## load package
library("MALDIquant")

## 9 point moving average
MALDIquant:::.movingAverage(rep(1:5, times=2), halfWindowSize=4)
# 2.778 2.778 2.778 2.778 2.778 3.222 3.222 3.222 3.222 3.222

## load example data
data("fiedler2009subset", package="MALDIquant")

## smooth spectra
s <- smoothIntensity(fiedler2009subset, method="MovingAverage",
                     halfWindowSize=2)

Run the code above in your browser using DataLab