Subsamples a specified number of observations for a given species from a BirdNET output dataset using one of three methods: stratified, random, or top confidence. Optionally saves the result to a CSV file.
Usage
birdnet_subsample(
data,
n,
method = c("stratified", "random", "top"),
save_to_file = FALSE,
file = NULL
)
Arguments
- data
A data frame containing BirdNET output. Relevant columns (e.g.,
common name
,confidence
,datetime
) are automatically detected by birdnet_detect_columns.- n
Integer. Total number of observations to subsample for each species in
data
.- method
Character string. Subsampling method to use. One of
"stratified"
,"random"
, or"top"
:"stratified"
Samples across confidence score strata (0.1 to 1 by 0.05 bins) evenly.
"random"
Randomly samples
n
observations."top"
Selects the top
n
observations with the highest confidence.
- save_to_file
Logical. If
TRUE
, saves the output data frame to a file named"subsampled_data.csv"
in the working directory. Default isFALSE
. Automatically set toTRUE
ifpath
is defined.- file
Character string or
NULL
. File path to save the output. IfNULL
andsave_to_file = TRUE
, the file is saved as "subsampled_data.csv" in the working directory.