advanceUnits: Compute adjusted dates

View source: R/dates.R

advanceUnits_cppR Documentation

Compute adjusted dates

Description

Advance a vector of dates by a given number of time units

Usage

advanceUnits_cpp(dates, n, unit, bdc, emr)

advanceUnits(dates, n, unit = c("Days", "Weeks", "Months", "Years", "Hours",
  "Minutes", "Seconds", "Milliseconds", "Microseconds"), bdc = c("Following",
  "ModifiedFollowing", "Preceding", "ModifiedPreceding", "Unadjusted",
  "HalfMonthModifiedFollowing", "Nearest"), emr = FALSE)

Arguments

dates

A Date vector with dates

n

An integer variable with the number of units to advance

unit

A character variable describing one of several supported values; the C++ version implements expects a corresponding integer value

bdc

A character variable describing one of several supported values, the C++ version implements expects a corresponding integer value

emr

A boolean variable select end-of-month, default is ‘FALSE’

Details

This function takes a vector of dates and returns another vector of dates of the same length returning at each position the date advanced by the given number of steps in the selected time unit, also respecting a business day convention and and of month boolean switch. Currently supported values for the time unit are ‘Days’, ‘Weeks’, ‘Months’ ‘Years’, ‘Hours’, ‘Seconds’, ‘Milliseconds’ and ‘Microseconds’; all are specified as integers. Note that intra-daily units are not currently supported for advancing ‘Date’ objects. Currently supported values for the business day convention are (starting from zero): ‘Following’, ‘ModifiedFollowing’, ‘Preceding’, ‘ModifiedPreceding’, ‘Unadjusted’, ‘HalfModifiedFollowing’ and ‘Nearest’.

Value

A Date vector with dates advanced according to the selected inputs

Examples

advanceUnits(Sys.Date()+0:6, 5, "Days", "Following")

RcppQuantuccia documentation built on Oct. 20, 2022, 1:07 a.m.