Learn R Programming

bizdays (version 0.2.2)

bizyears: Computes business days between two dates in years

Description

Returns the business days between 2 dates in years taking into account the provided Calendar (or bizdays.options$get("default.calendar")).

Usage

bizyears(from, to, cal = bizdays.options$get("default.calendar"))

Arguments

from
the initial dates
to
the final dates
cal
an instance of Calendar

Value

numeric objects representing the amount of business days in years.

Date types accepted

The arguments from and to accept Date objects and any object that returns a valid Date object when passed through as.Date, which include all POSIX* classes and character objects with ISO formatted dates.

Recycle rule

These arguments handle the recycle rule so vectors of dates can be provided and once those vectors differs in length the recycle rule is applied.

Date adjustment

from and to are adjusted when nonworking dates are provided. Since bizdays function returns the amount of business days between 2 dates, it must start and end in business days. The default behavior, that is defined in Calendar's instantiation with adjust.from and adjust.to, reproduces the Excel's NETWORKDAYS. A common and useful setting is adjust.to=adjust.next which moves expiring maturities to the next business day, once it is not.

Details

The business days are converted to years by a division by Calendar's dib attribute. This is equivalent to

cal <- Calendar(holidays, weekdays=c("saturday", "sunday"), dib=252)
bizdays("2013-01-02", "2013-01-31", cal)/cal$dib

See Also

bizdays for business days.

Examples

Run this code
data(holidaysANBIMA)
cal <- Calendar(holidaysANBIMA, weekdays=c("saturday", "sunday"), dib=252)
bizyears("2013-01-02", "2013-01-31", cal)

Run the code above in your browser using DataLab