date_in_range: Test where a date falls relative to a date range

View source: R/comparisons.R

date_in_rangeR Documentation

Test where a date falls relative to a date range

Description

Test where a date falls relative to a date range

Usage

date_in_range(target, start, end, .before = FALSE, .ongoing = TRUE,
  .during = TRUE, .after = FALSE)

Arguments

target

The date of interest

start

The starting date of the range

end

The ending date of the range

.before

The value to assign if the date falls before the range (default FALSE)

.ongoing

The value to assign if the date falls after start, and end is NA (default TRUE)

.during

The value to assign if the date falls within the range (default TRUE)

.after

The value to assign if the date falls after the range (default FALSE)

Details

The return values can be logical, character, or numeric. The interval for within includes the start and end dates.

Value

The return type is determined by the user. The default is logical.

Examples

date_in_range(iso_to_posix("2018-03-14T12:34"), iso_to_posix("2018-03-11T12:34"), iso_to_posix("2018-03-18T12:34"))
date_in_range("2018-03-14", "2018-03", "2018-03-18T12:34")
date_in_range(iso_to_posix("2018-03-14T12:34"), iso_to_posix("2018-03-15T12:34"), iso_to_posix("2018-03-18T12:34"))
date_in_range(iso_to_posix("2018-03-14T12:34")+(1:10)*24*2600,
  iso_to_posix("2018-03-11T12:34"),
  iso_to_posix("2018-03-18T12:34"))
date_in_range(iso_to_posix("2018-03-09T12:34")+(1:10)*24*3600,
  iso_to_posix("2018-03-11T12:34"),
  c(rep(iso_to_posix("2018-03-15T12:34"),9), NA),
  .before="BEFORE", .ongoing="ONGOING", .during="DURING", .after="AFTER")

qPharmetra/PMDatR documentation built on April 7, 2024, 5:42 p.m.