dateArith: Date arithmetic

Description Usage Arguments Details See Also Examples

Description

Bunch of convenience functions to do simple arithmetic on dates.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
addDays(date, n = 1)

subtractDays(date, n = 1)

addBizDays(date, n = 1, hol = NULL)

subtractBizDays(date, n = 1, hol = NULL)

addMonths(date, n = 1)

subtractMonths(date, n = 1)

Arguments

date

A 'datelike' object

n

An integer number of days/months to add/subtract (default 1)

hol

A 'datelike' object containing holiday dates

Details

Increment or decrement the vector 'date' forward or backward by 'n' day(s), 'n' business day(s), or 'n' months. Business days are considered to be Monday through Friday. A vector of holiday dates can be passed in.

See Also

is.DateLike

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
x <- seq(from=as.Date("2001-01-01"), to=as.Date("2001-01-31"), by="day")
ax <- addDays(x, 3)
difftime(x, ax)

x <- seq(from=as.Date("2001-01-01"), to=as.Date("2001-01-31"), by="day")

sx <- subtractDays(x, 3)
difftime(x, sx)

x <- seq(from=as.Date("2001-01-01"), to=as.Date("2002-06-01"), by="months")
h <- as.Date("2001-07-02")
ax <- addBizDays(x, hol=h)

## End(Not run)

pchristi99/pcLib documentation built on June 25, 2019, 2:23 p.m.