binDetectionData: Bin Detection Data to Time Bins

View source: R/binDetectionData.R

binDetectionDataR Documentation

Bin Detection Data to Time Bins

Description

Transforms detection data to presence-type data with user specified time bin (e.g. hourly or daily presence).

Usage

binDetectionData(
  x,
  bin,
  columns = c("species", "project"),
  rematchGPS = TRUE,
  gpsGroup = NULL
)

Arguments

x

dataframe of deteciton data

bin

the amount time to bin by, must be a character of the form "#unit" or "unit" e.g. "2hour" or "day"

columns

names of the columns in x that define which rows should still be considered distinct even if their times are in the same bin. For example, two calls from the same species in one hour should result in one row of hourly presence, but two calls from different species in one hour should result in two separate rows of hourly presence.

rematchGPS

logical flag, if TRUE then if columns Longitude and Latitude are present in x then they will be rematched to the outputs. Note that this is imprecise - the time used for rematching the outputs is the center of each output time bin.

gpsGroup

the name of the column in x that denotes different GPS groupings within the data, usually something like "site" or "deployment." Not needed if all data are from the same location.

Value

a dataframe where each row represents detection presence of one time unit

Author(s)

Taiki Sakai taiki.sakai@noaa.gov

Examples

dets <- data.frame(
   UTC = as.POSIXct(c('2020-04-04 12:20:00', '2020-04-04 12:40:00', '2020-04-04 13:20:00')),
   species = c('whale', 'whale', 'dolphin'),
   call = c('a', 'b', 'c'))
# two rows of outputs
binDetectionData(dets, bin='1hour', columns='species')
# adding "call" creates 3 rows of outputs
binDetectionData(dets, bin='1hour', columns=c('species', 'call'))


PAMscapes documentation built on April 4, 2025, 2:17 a.m.