NA output usin add.bizdays in R

50 Views Asked by At

I create a custom calendar using create.calendar function from bizdays package and a vector with all 2023 year days in vector Date_A. I need to add 8 working days to every day and store it in Date_B, for that reason I used add.bizdays function but the output I get NA values for last 19 values but they should be valid dates, for example for "2023-12-13" in Date_A the output in Date_B should be "2023-12-26" but gives an NA. How can I achieve a valid result instead of that misssing values? The code is as follows:

library(bizdays)
library(lubridate)

feriados_CR <- as.Date(c(
  "2023-01-01","2023-01-02","2023-01-03","2023-01-04","2023-01-05","2023-01-06","2023-04-06",
  "2023-04-07","2023-04-10","2023-05-01","2023-07-24","2023-08-02","2023-08-14","2023-09-03",
  "2023-09-15","2023-12-01","2023-12-25"))

calendar <- create.calendar("Costa_Rica",
                              holidays = feriados_CR,
                              weekdays =  c("saturday", "sunday"))


Date_A <- seq(ymd("2023-01-01"), ymd("2023-12-31"), by = "days")

Date_B <- add.bizdays(Date_A, 8, "Costa_Rica")
0

There are 0 best solutions below