Skip to contents

This function generates a Power Spectral Density (PSD) plot from the average of multiple input Waves (e.g., population, species, etc,). The line is soothed with local regression (LOESS).

Usage

spectrum_pop(
  waves,
  freq_res = 300,
  fun = "mean",
  wn = "hanning",
  loess_span = 0.1,
  conf_level = 0.95,
  color = "green4",
  mean_width = 1,
  ci_alpha = 0.3,
  title_y = "",
  title_x = "Frequency (kHz)",
  show_x_labs = TRUE,
  show_n = TRUE,
  binomial = NULL,
  save_to = NULL,
  save = FALSE,
  width = 960,
  height = 540,
  dpi = 200,
  ...
)

Arguments

freq_res

Numeric. The frequency resolution to be used for the frequency spectrum analysis. Use this argument consistently for standardized measurements across recordings with different sampling rate. Default is 10 Hz per frequency bin.

loess_span

The span of the LOESS smoothing, as a proportion. Higher values result in smoother lines. Default is 0.05.

conf_level

Numeric. Confidence interval level. Default is 0.95 (95%).

ci_alpha

Numeric. Transparency level for the confidence interval ribbon. Default is 0.7 (70%).

title_y

Character. Title for the Y-axis. Empty by default.

title_x

Character. Title for the X-axis. Default is "Frequency (kHz)".

show_x_labs

Logical. If TRUE, the labels (i.e., numbers) are shown in the X-axis. Defaults to TRUE.

show_n

Logical. If TRUE, the number of samples (i.e., recordings) is shown as "n=" on the top-right of the plot.

binomial

Character. The binomial name of the species. Empty by default.

...

Other arguments passed to meanspec() from the seewave package.

wave

An object of class Wave containing the audio data to be analyzed.

mean_col

Character. Color for the line representing the mean PSD.

line_width

Numeric. Width of the mean line.

ci_col

Character. Color for the confidence interval ribbon.

Value

An averaged and smoothed power spectral density plot representing all the Waves in the list provided to the waves argument. The plot shows the mean and confidence interval (95% by default) along with the peak frequency, the scientific name of the species as provided in the binomial argument, and the number of samples (Wave objects) from which the mean was calculated.

Examples

 if (FALSE) { # \dontrun{
library(RthopteraSounds)
data(coryphoda)
data(tettigonia)
# Assume the two Waves are two individuals from the same species
waves_list <- c(coryphoda, tettigonia)
population_spectrum(waves = waves_list, freq_res = 50, show_x_labs = TRUE,
title_x = "", show_n = TRUE, binomial = "Coryphoda albidicollis")
} # }