I have a new computer. I installed R and RStudio, and I am now struggling to run some of my existing code. For example, R and/or the (excellent) clock package does not like my time zone, which is set to 'UTC'. See reprex below.
I tried to set the time zone manually in my .Renviron file, (TZ="America/New_York") but that did not help. I also looked at the output of the set command from my Command Prompt, but I did not see a system environment variable for time zone either.
Any ideas?
library(clock)
#> Error: package or namespace load failed for 'clock':
#> .onLoad failed in loadNamespace() for 'clock', details:
#> call: NULL
#> error: 'UTC' is not a known time zone.
sessionInfo()
#> R version 4.1.0 (2021-05-18)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_United States.1252
#> [2] LC_CTYPE=English_United States.1252
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United States.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] crayon_1.4.1 tzdb_0.1.2 digest_0.6.27 withr_2.4.2
#> [5] magrittr_2.0.1 reprex_2.0.0 evaluate_0.14 highr_0.9
#> [9] stringi_1.7.3 rlang_0.4.11 cli_3.0.1 rstudioapi_0.13
#> [13] fs_1.5.0 vctrs_0.3.8 ellipsis_0.3.2 rmarkdown_2.9
#> [17] tools_4.1.0 stringr_1.4.0 glue_1.4.2 xfun_0.24
#> [21] yaml_2.2.1 compiler_4.1.0 htmltools_0.5.1.1 knitr_1.33
Ah hah! I see a new error message... but I dont know what to do now.
Is R or the library in a bad place?
Thank you Davis, for the help, and for creating clock I do love it!
P.S. I edited the path to the library, it contains an odd character... a letter with an accent. I did not want to post it publicly.
P.P.S. I have another clue.... my win-library folder contains two subfolders, one named 3.4 one named 3.5 They were created when I copied files/folders to my current computer from an old one... so I think that path is not valid. There is no folder named 4.1.
My apologies, I was confused by the Win11 GUI (Windows Explorer), I do have a directory named 4.1, and clock is in it. I understand that now thanks to you and .libPaths()
That character is likely the issue. In the short term you could move the R package library to a location with a simpler path like you suggest and teach .libPaths() about it. That would probably fix it. In the longer term I'll hopefully be able to fix this in tzdb.
Thanks again Davis! The fix was rather easy, once I found the solution, (thank you HenrikBengtsson) which was to edit/create ~/.Renviron and include the line: