This example demonstrates the use of rPeaks for the deconvolution of monthly sunspots data using a Lorentzian profile.
First, load the packages we need
library(datasets) library(rPeaks) library(stats) library(graphics)
Next, generate the spectrum
smf <- abs(fft(spec.taper(as.vector(sunspot.month),p=0.5)))
Remove the background from the spectrum
p <- smf-SpectrumBackground(smf,iterations=100)
Generate a Lorentzian responce vector with FWHM=pi*5
x <- 1:100 Z <-1/(1+((x-pi*5)/5)^2)
Deconvolve the low-frequency region of spectrum
l <- SpectrumDeconvolution(p[1:500],Z,iterations=20,boost=1.1, repetitions=4)
Now, plot the results
plot(p,type="p", xlim=c(0,200), ylim=c(0,80000)) lines(l,col="red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.