Skip to contents

Uses dates to join site-level data (coordinates and site ids) to the meta data. If the site data have only single dates, then a buffer before and after is used to determine which recordings belong to that site observation. Can join by site ids alone if set by_date = NULL.

Usage

add_sites(
  meta,
  sites,
  buffer_before = 0,
  buffer_after = NULL,
  by = c("site_id", "aru_id"),
  by_date = "date_time",
  quiet = FALSE
)

Arguments

meta

Data frame. Recording metadata. Output of clean_metadata().

sites

Data frame. Site-level data from clean_site_index().

buffer_before

Numeric. Number of hours before a deployment in which to include recordings. NULL means include the time up to the last deployment. Coupled with buffer_after, this creates a window around a date/time in which to join recordings to the site-level data. Ignored if sites has both a start and end column for date/times. Default 0.

buffer_after

Numeric. Number of hours after the deployment in which to include recordings. NULL means include the time up to the next deployment. Coupled with buffer_before, creates a window around a date/time in which to join recordings to the site-level data. Ignored if sites has both a start and end column for date/times. Default NULL.

by

Character. Columns which identify a deployment in sites as well as meta, besides date/time, which are used to join the data. Default is site_id and aru_id.

by_date

Character. Date/time type to join data by. date is faster but date_time is more precise. Default date_time. NULL means ignore dates and join only with by columns (dplyr::left_join()).

quiet

Logical. Whether to suppress progress messages and other non-essential updates.

Value

A data frame of metadata with site-level data joined in.

Examples

m <- clean_metadata(project_files = example_files)
#> Extracting ARU info...
#> Extracting Dates and Times...
s <- clean_site_index(example_sites_clean,
  name_date = c("date_time_start", "date_time_end")
)
m <- add_sites(m, s)
#> Joining by columns `date_time_start` and `date_time_end`

# Without dates (by site only)
m <- clean_metadata(project_files = example_files)
#> Extracting ARU info...
#> Extracting Dates and Times...
eg <- dplyr::select(example_sites_clean, -date_time_start, -date_time_end)
s <- clean_site_index(eg, name_date_time = NULL)
m <- add_sites(m, s, by_date = NULL)
#> Ignoring dates - Joining with `by` columns only (`by_date == NULL`)