closest_date: This finds the closest date to a given date that exists in a...

View source: R/utils.R

closest_dateR Documentation

This finds the closest date to a given date that exists in a dataset.

Description

This finds the closest date to a given date that exists in a dataset.

Usage

closest_date(data, date, type = "all", force_val = T)

Arguments

data

A data frame that includes a column 'timestamp'

date

The date you want to match'

type

Default "all", which returns closest date overall. Other options are "before", "after", "beforeequal", and "afterequal"'

force_val

Default True. If True, then the function will return the "all" type if there is no date given for the type

Examples

closest_date(data = df, date = "2020-01-01", type = "all", force_val = T)

tlcaputi/gtrendR documentation built on Nov. 3, 2022, 10:46 p.m.