find_peaks: Find peaks in a periodogram

View source: R/find-peaks.R

find_peaksR Documentation

Find peaks in a periodogram

Description

This function locates the peaks in a pregenerated periodogram. Detection is based on pracma::findpeaks. Only the significant (i.e. power > signif_threshold) peaks are extracted.

Usage

find_peaks(data, n_peaks = 3)

Arguments

data

behavr::behavr table representing a periodogram, as returned by periodogram

n_peaks

maximal numbers of peak to be detected

Value

behavr::behavr table that is data with an extra column peak. peak is filled with zeros except for rows match a peak. In which case, rows have an integer value corresponding to the rank of the peak (e.g. 1 for the first peak).

References

See Also

  • periodogram – to generate a periodogram in a first place

  • ggetho::geom_peak – a layer to show peaks on a periodogram

Examples

data(dams_sample)
# only a half of the individuals for the sake of the example
dt <- dams_sample[xmv(region_id) %in% (1:16 * 2)]
per_dt_xs <- periodogram(activity, dt, FUN = chi_sq_periodogram)
per_dt_xs_with_peaks <- find_peaks(per_dt_xs)
per_dt_xs_with_peaks[peak == 1]

rethomics/zeitgebr documentation built on April 11, 2024, 2:28 a.m.