Hello. The code is from the READ.me. I've encountered an error and was able to reproduce the issue using an example provided in the documentation. The issue is when a value is provided to the year, from, or to parameters calendR errors out.
I think the issue is a result of changes in R versions. Later versions now result in an error when the condition within an if() statement has a length gt 1.
A possible solution could be to perform a multi-stage conditional check, such as:
check if special.days is of length one
then, if ^ is true, check if special.days is equal to weekend
Error in if (special.days != "weekend") { : the condition has length > 1
Reproducible Example
# Vector of NA which length is the number of days of the year or month
myfills <- rep(NA, 365)
# myfills <- rep(NA, 366) # For leap years
# Add the events to the desired days
myfills[c(1:4, 50, 300:315)] <- "Holidays"
myfills[16] <- "Birthday"
# works
calendR::calendR(
special.days = myfills,
special.col = 2:3, # Add as many colors as events
legend.pos = "right" # Add a legend if desired
)
# fails
calendR::calendR(
year = "2024",
special.days = myfills,
special.col = 2:3, # Add as many colors as events
legend.pos = "right" # Add a legend if desired
)
Hello. The code is from the READ.me. I've encountered an error and was able to reproduce the issue using an example provided in the documentation. The issue is when a value is provided to the year, from, or to parameters calendR errors out.
I think the issue is a result of changes in R versions. Later versions now result in an error when the condition within an
if()
statement has a length gt 1.A possible solution could be to perform a multi-stage conditional check, such as:
I added
tolower(special.days)
for robustnessError Message
Reproducible Example
Session Info