I have a vector of date objects (yyyy-mm-dd) and I want to determine if any of them are on weekend or not. Is there a function that can determine this straighta
After looking a lot about this topic, I found this solution particularly simple using the package RQuantLib
install.packages("RQuantLib")
library(RQuantLib)
isBusinessDay(calendar="WeekendsOnly", dates=yourdatesofinterest)
You can modify this code with different calendars to add to the weekends different sets of holidays in different countries (below just an example, but they have many more).
isBusinessDay(calendar="UnitedStates", dates=yourdatesofinterest)
isBusinessDay(calendar="UnitedStates/Settlement", dates=yourdatesofinterest)
isBusinessDay(calendar="UnitedStates/NYSE", dates=yourdatesofinterest)
isBusinessDay(calendar="Sweden", dates=yourdatesofinterest)
isBusinessDay(calendar="Mexico", dates=yourdatesofinterest)
I hope it helps somebody