fit_peaks | R Documentation |
Functions implementing fitting of peaks in a class-agnostic way. The fitting
refines the location of peaks and value of peaks based on the location of
maxima and minima supplied. This function is to be used together with
find_peaks()
or find_valleys()
.
fit_peaks(
x,
peaks.idx,
span,
x.col.name = NULL,
y.col.name,
method,
max.span = 5L,
maximum = TRUE,
keep.cols = NULL
)
fit_valleys(
x,
valleys.idx,
span,
x.col.name = NULL,
y.col.name,
method,
max.span = 5L,
maximum = FALSE,
keep.cols = NULL
)
x |
generic_spct or data.frame object. |
peaks.idx , valleys.idx |
logical or integer Indexes into |
span |
odd integer The span used when refining the location of maxima or
minima of |
x.col.name , y.col.name |
character Name of the column of |
method |
character The method to use for the fit. |
max.span |
odd integer The maximum number of data points used when when refining the location of maxima and minima. |
maximum |
logical A flag indicating whether to search for maxima or minima. |
keep.cols |
logical Keep unrecognized columns in data frames |
The only method currently implemented is "spline"
based on
a call to splinefun
in a window of width span
centred on each peak pointed at by peaks.idx
. A spline fitted to
a narrow window will usually locate the position of the peak in the
column named by the argument passed to x.col.name
better than
estimating the true height of the peak in the column named by the argument
passed to y.col.name
.
An R object of the same class as x
containing the fitted
values for the peaks, and optionally the unmodified values at the rows
matching peaks.idx
or valleys.idx
for other retained columns.
These functions are not meant for everyday use. Use option
refine.wl = TRUE
of methods peaks()
and valleys()
instead.
peaks <- find_peaks(sun.spct[["s.e.irrad"]], span = 31)
fit_peaks(sun.spct, peaks, span = 31,
y.col.name = "s.e.irrad", method = "spline")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.