Rounds sampling intervals that are close, but not exactly the time interval of interest (e.g., 240 s instead of 300 s). This can be performed on multiple time intervals, but only using a single tolerance value. This function prepares the data to be analyzed by segment_behavior, which requires that all time intervals exactly match the primary time interval when analyzing step lengths and turning angles. Columns storing the time intervals and dates must be labeled dt and date, respectively, where dates are of class POSIXct.

round_track_time(dat, id, int, tol, time.zone = "UTC", units)

Arguments

dat

A data frame that contains the sampling interval of the observations.

id

character. The name of the column storing the animal IDs.

int

numeric. A vector of the time interval(s) of on which to perform rounding.

tol

numeric. A single tolerance value on which to round any int that were specified.

time.zone

character. Specify the time zone for which the date-times were recorded. Set to UTC by default. Refer to base::OlsonNames to view all possible time zones.

units

character. The units of the selected time interval int, which can be selected from one of "secs", "mins", "hours", "days", or "weeks".

Value

A data frame where dt and date are both adjusted based upon the rounding of time intervals according to the specified tolerance.

Examples

#load data
data(tracks)

#subset only first track
tracks<- tracks[tracks$id == "id1",]

#calculate step lengths and turning angles
tracks<- prep_data(dat = tracks, coord.names = c("x","y"), id = "id")

#round times to nearest interval of interest (e.g. 3600 s or 1 hr)
tracks<- round_track_time(dat = tracks, id = "id", int = 3600, tol = 180, time.zone = "UTC",
                          units = "secs")