peaks(x, span=3, strict=T)
peaks will find the local maxima in each
column of
x. Missing values are allowed.
span centered at that element.
The default value is
3, meaning that a peak is bigger than both of its
neighbors.
TRUE, an element
must be strictly greater than all other values in its window to be considered
a peak.
x of logical values.
Values that are
TRUE correspond to local peaks in the data.
All elements within a halfspan of the end of
a sequence or within a halfspan of a missing value are
FALSE.
# find and plot peaks in spectrum p <- spectrum(lynx,span=c(3,3), plot=T) peakfreqs <- p$freq[peaks(p$spec, span=5)] abline(v=peakfreqs, col=2) # draw vertical lines at peak frequencies peakfreqs/peakfreqs[1]