CountWorkDays: Count Work Days Between Two Dates

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/DescTools.r

Description

Returns the number of work days between two dates taking into account the provided holiday dates.

Usage

1
CountWorkDays(from, to, holiday = NULL, nonworkdays = c("Sat", "Sun"))

Arguments

from

the initial dates

to

the final dates

holiday

a vector with dates to be excluded.

nonworkdays

a character vector containing the abbreviations of the weekdays (as in day.abb) to be considered non work days. Default is c("Sat","Sun").

Details

The function is vectorised so that multiple initial and final dates can be supplied. The dates are recycled, if their number are different

Value

an integer vector

Author(s)

Andri Signorell <andri@signorell.net>

See Also

weekdays, Date Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from <- as.Date("2019-01-01") + rep(0, 10)
to <- as.Date("2020-01-15") + seq(0, 9)

CountWorkDays(from, to)

x <- seq(from[1], from[1]+11, "days")
data.frame(
  date = x, 
  day  = Format(x, fmt="ddd"))

CountWorkDays(from = min(x), to = max(x), holiday = c("2019-01-06", "2019-01-07"))

DescTools documentation built on June 17, 2021, 5:12 p.m.