-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected error - conditional in if statement has length gt 1 #30
Comments
I am also seeing this error. The reproducible example given by @SaintRod is directly from the README. This happens anytime I attempt to pass a list to the special.days argument that has a length greater than 1. The only workaround I've found is to create the events variable like so,
This unfortunately forfeits the users ability to have separate coloration for different events and have named events, so I would consider that an unacceptable workaround. |
@parkerbailey: Can you reproduce this error with calendRio? I tried @SaintRod's example and got the following result: If you encounter issues with calendRio, please let me know. I'll happily fix things there and provide the solution as a PR here, if there is interest. |
@mschilli87 Yes, I can replicate this error with CalendRio. I did some more digging, and it has something to do with how
could perhaps be changed to
I'm not certain if this would work as I have no way to test it at the moment, but it's the best idea I've found so far. |
Could you provide me with some copy/paste-able code that triggers this in calendRio, along with a full session info? Then I'll have a look and push a fix over the weekend. Once I can reproduce it, it should be easy to fix. |
Example code:
Session info:
|
Reproduced. Will work on a fix. |
I have a fix that 'works'. However, your code would't work on this either because (as per the documentation and error message) ' The following would work with my fixed version: calendR(
year = 2025,
special.days = events,
special.col = c("pink", "lightblue")
) As would the following: events <- rep(NA, 366)
events[222:226] <- "Event 1"
events[245] <- "Event 2"
calendR(
special.days = events,
special.col = c("pink", "lightblue")
) Note, however, that both of the above also work on the latest release of both, I'll release calendRio v 0.2.1 with the fix either way these days and will open a PR here as well, but you shouldn't need to wait for that to generate your calendar(s) as long as you provide the correct number of days for the year of interest. Could you please test and confirm? |
Ensure `length(special.days) == 1L` before comparing to `"weekends"`. This is requried for newer versions of R. As far as I can tell, this does not limit any functionality, but masks the informative error message when specifying the wrong number of days (i.e. 365 for a leap year) with an uninformative one. This commit fixes issue R-CoderDotCom#30. Signed-off-by: Marcel Schilling <[email protected]>
Ensure `length(special.days) == 1L` before comparing to `"weekends"`. This is requried for newer versions of R. As far as I can tell, this does not limit any functionality, but masks the informative error message when specifying the wrong number of days (i.e. 365 for a leap year) with an uninformative one. This commit fixes issue R-CoderDotCom#30. Signed-off-by: Marcel Schilling <[email protected]>
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
The text was updated successfully, but these errors were encountered: