I want to add days to a date in R, except Saturdays and Sundays and specific holidays. Suppose I have a dateset :
d <- dmy("25-7-2016","26-7-2016")
days <- c(3:4)
data <- data.frame(d,days)
data
I want to add #days (days column) to a date (d column) I have tried the following code:
library(bizdays)
library(lubridate)
cal <- Calendar(weekdays=c('sunday', 'saturday'))
data$f <- offset(d, days, cal)
data
I can get the days without considering Saturdays and Sundays. But I want to exclude a specific holiday i.e. 27-7-2016. I tried to incorporate this specific holiday but getting an error. The code which I tried is as follows:
holiday <- dmy("27-7-2016")
cal <- Calendar(holiday,weekdays=c('sunday', 'saturday'))
data$f <- offset(d, days, cal)
data
Could you please help me to get is solved. Thanks in anticipation!