Created
April 17, 2020 09:29
-
-
Save wilsonfreitas/4f68db84980091c807300a7ff9a54068 to your computer and use it in GitHub Desktop.
bizdays BUG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(bizdays) | |
library(lubridate) | |
create.calendar(name='MyCalendar', | |
weekdays=c('saturday', 'sunday'), | |
start.date = ymd("2019-12-28"), | |
end.date = ymd("2021-01-01")) | |
calendars()[["MyCalendar"]] | |
ts_begin <- seq(as.Date("2020-01-01"), length=13, by="1 month") - days(1) | |
NrDays <- numeric() | |
for (i in 1:12) { | |
NrDays[i] <- bizdays(ts_begin[i], ts_begin[i+1], "MyCalendar") | |
cat(format(ts_begin[i]), ":", format(ts_begin[i+1]), "=", NrDays[i], "\n") | |
} | |
# Not accounting for holidays.... | |
# These results are expected: Jan: 23 Feb: 20 , March:22, April:22 , May:21 , Jun:22, Jul:23, Aug: 22, Sep:22, Oct:22, Nov:22 and Dec;23 | |
# | |
# Instead I get (from jan-dec): NrDays [1] 23 20 21 22 21 21 23 21 22 22 20 23 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment