Skip to contents

This function processes and summarizes acoustic indices from a data frame. It formats data based on its origin, either "kaleidoscope" or "soundecology2", and computes summary statistics such as mean, median, mode, minimum, and maximum values for each acoustic index. Additionally, it identifies the recording files that are closest to each of these summary statistics.

Usage

indices_summary(df, origin = "soundecology2")

Arguments

df

A data frame containing acoustic indices. Expected column names depend on the origin parameter. For "kaleidoscope" data, expected columns include IN.FILE, CHANNEL, and several acoustic indices (ndsi, cent, etc.). For "soundecology2" data, columns should include file_name, sensor_id, and datetime.

origin

A character string specifying the source of the data. Options are "kaleidoscope" or "soundecology2". Default is "kaleidoscope".

Value

A data frame containing summary statistics (mean, median, mode, max, min) for each acoustic index, with the associated recording file closest to each statistic.

Examples

# Example with kaleidoscope data
df <- data.frame(in.file = c("unit1_20220101_123000.wav", "unit2_20220101_124000.wav"),
                 channel = c(0, 1), ndsi = c(0.3, 0.7), cent = c(200, 300))
indices_summary(df, origin = "kaleidoscope")
#> Error in dplyr::select(df, -offset): Can't select columns that don't exist.
#>  Column `offset` doesn't exist.

# Example with soundecology2 data
df2 <- data.frame(file_name = c("unit1_2022-01-01 12:30:00", "unit2_2022-01-01 12:40:00"),
                  sensor_id = c("unit1", "unit2"), datetime = c("2022-01-01 12:30:00", "2022-01-01 12:40:00"))
indices_summary(df2, origin = "soundecology2")
#> Error in dplyr::group_by(df, sensor_id, channel, index): Must group by variables found in `.data`.
#> Column `channel` is not found.
#> Column `index` is not found.