Add time (in seconds since tagon and perhaps as datetimes in UTC and/or local timezone) to a tibble or data-frame with regularly sampled data

add_event_depths(x, start_x, z, sampling_rate, start_offset = 0, tagon_time)

Arguments

x

input data: vector or data frame with event times as datetimes, or in seconds since tagon. Datetimes are assumed to be UTC.

start_x

name (no quotes needed) of variable in x that gives event times. Not needed if x is a vector or has only one column.

z

depth data: sensor data structure, vector, matrix, tibble, or data frame. If not a sensor structure, then sampling_rate is required. If tibble or df it should have only one column (depth data).

sampling_rate

sampling rate of depth in Hz (required if x is not a sensor data structure, and ignored if it is)

start_offset

time (in seconds) between start of tag recording and the first recorded sample in z. Ignored (and pulled from metadata) if x is a sensor data structure. default: 0

tagon_time

string giving the tag recording start time. Can be found in tag_dataset$info$dephist_device_datetime_start. Format: day month year hours minutes seconds. Required if times in x are datetimes.

Value

A data.frame with the data (one row per event) and additional column depth (in meters) of the animal at the start time of the event. Note: if you want to grab and summarize depth data for longer intervals, consider interval_join or find_dives and dive_stats