In my package vignette, I have plaftform dependant code:
x <- c("01JAN2020:00:00:00", "15JAN2020:00:00:00")
# This is plaftform dependant
Sys.setlocale("LC_TIME", "English")
as.Date(x, "%d%b%Y")
# [1] "2020-01-01" "2020-01-15"
The vignette passes R CMD check --as-cran
on my Windows machine, but would fail on a Linux machine (would need locale = "en_US"
).
Is there good practice here? Would it work if I submit my package to CRAN as is? (checks seem to be run on different platforms on CRAN according to https://cran.r-project.org/web/checks/check_summary.html)
CodePudding user response:
I do not know if you can have platform-specific sources for vignettes. However, I would say that you usually don't need that.
In your example, I can only see a need to have anything platform-specific if the purpose is to show the user how to do it in a platform-specific way.
If that's the case, show how to do it on all platforms but don't evaluate the code. Then create the result in a platform-agnostic approach (maybe using dput
output).
Else, just use a platform-agnostic approach, such as having the character strings in standard %Y-%m-%d %H:%M:%S
format. In your example Sys.setlocale("LC_TIME", "C")
might also be a useful approach.