return_k_date: Return the k-th most recent or oldest date / datetime from a...

View source: R/return_k_date.R

return_k_dateR Documentation

Return the k-th most recent or oldest date / datetime from a vector

Description

Return the k-th most recent or oldest date / datetime from a vector

Usage

return_k_date(x, k, decreasing = TRUE)

Arguments

x

A vector of date-time

k

Integer specifying the k-th value to return from the vector

decreasing

Logical. Specifies whether to return most recent or oldest

Examples

library(lubridate)
dates <- c(ymd("2018-01-01"), ymd("2016-01-31"), ymd("2017-01-31"))
return_k_date(dates, k = 2)

martinctc/tstoolbox documentation built on Nov. 20, 2024, 3:55 p.m.