I have just got a new laptop and as I was testing my R codes in a new RStudio/R environment I encountered an issue with lubridate labels that I have not been able to figure out yet. I suspect some package incompatibility, but any hint / way forward to investigate and solve the issue would be helpful. Thank you!
RStudio 2023.09.1 Build 494
sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
other attached packages:
[1] lubridate_1.9.3
I have tested the following examples with the month() function, reproduced from the lubridate documentation, the first example is working seamlessly, but as soon as I introduce labels I get a factor error label - I get a similar error with other lubridatefunctions (e.g. wday())
month(ymd(080101))
[1] 1
label
logical. TRUE will display the month as a character string such as "January." FALSE will display the month as a number.
month(ymd(080101), label = TRUE)
Error in factor(x, ..., ordered = TRUE) :
invalid 'labels'; length 10 should be 1 or 12
Thank you both for your inputs. I rebooted my laptop and the functions this time indeed worked smoothly in the console... but not in my script. I have checked that before getting the error in the script I indeed get the expected output
This led me to identify that lubridate functions actually work correctly when LC_TIME is set to English but is failing when set to French, which is the locale setting I am using in my script and the setting I had used in my previous tests in the console (but had not exported with the session information )
Interestingly, it seems that it may be linked to my default configuration being in Swiss German, which possibly creates some incompatibilities with French but not with English.
My guess is that I now probably have to set these locale variables to English in my R profile to solve the issue (which was probably the case in my old configuration), but would be interested in better understanding how these locale variables work exactly
If you find that lubridate is an issue on a particular locale that is reproducible, it may be useful to raise it as an issue on the lubridate github issues page so that it could be addressed to help you and others
Good that you found a solution for yourself, well done
Noted, I was a bit too tired yesterday to be as systematic as I wanted, but will investigate more to be sure that reproducible and fully documented and open an issue on the lubridate GitHub
Thanks again for the help, this has been very helpful for me to eliminate possible issues and focus my investigations