Setting default calendar in .Rprofile

2018-06-25

Setting default calendar in .Rprofile

That’s the way I use bizdays, I set the default.calendar in my .Rprofile. Since I am always using holidaysANBIMA holidays I create and set the default calendar in my .Rprofile.

library(bizdays)
create.calendar(name='ANBIMA', holidays=holidaysANBIMA, weekdays=c('saturday', 'sunday'))
bizdays.options$set(default.calendar='ANBIMA')

If you put these 3 lines of code at the end of your .Rprofile you don’t have to instantiate the calendar every time you use bizdays. You can simply

from_dates <- c('2013-07-12', '2012-06-13')
to_dates <- seq(as.Date('2014-02-17'), as.Date('2016-07-21'), by='months')
bizdays(from_dates, to_dates)
##  [1]  153  442  194  483  234  526  276  570  321  613  364  655  404  695
## [15]  446  735  486  779  529  822  571  863  614  904  654  946  695  987
## [29]  738 1029

And it works with any of bizdays functions: