1

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"
Stupid_Intern
  • 3,382
  • 8
  • 37
  • 74

1 Answers1

0

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"
Stupid_Intern
  • 3,382
  • 8
  • 37
  • 74