rdatetimebizdays

Yield next business day in R


I need to calculate next business day in R with two parameters today's date and a data.frame having list of dates which are holidays

I tried but it's yielding today's date only

> cal <- create.calendar("MyCalendar", holidays = as.timeDate(HolidayList$Holidays), weekdays=c("sunday"))
> following(Sys.Date(),'MyCalendar')
[1] "2019-03-20"
> adjust.next(Sys.Date(),'MyCalendar')
[1] "2019-03-20"

Solution

  • offset function did the trick

    > offset(Sys.Date(),1,'MyCalendar')
    [1] "2019-03-21"
    

    also add.bizdays(dates, n, cal) function works the same

    > add.bizdays(Sys.Date(),3,'MyCalendar')
    [1] "2019-03-25"