nearest_time: Match to nearest time

View source: R/nearest_time.R

nearest_timeR Documentation

Match to nearest time

Description

Finds nearest time stamp in time 2 for each row of time 1. Optionally can include difference.

Usage

nearest_time(
  time1,
  time2,
  unit = "secs",
  output_dif = FALSE,
  break_ties = "earlier"
)

Arguments

time1

vector of timestamps (class of "POSIXct" "POSIXt")

time2

vector of timestamps to campare time 1 to (class of "POSIXct" "POSIXt")

unit

time unit ("secs", "mins", "hours", "days", or "weeks"): defualt is "secs"

output_dif

Logical specifying whether or not the time difference for each row should be output (default is FALSE

break_ties

if to times from time2 are equidistant should the "earlier" or "later" time be chosen (default is "earlier")


ailich/mytools documentation built on Jan. 7, 2023, 11:16 a.m.