0

I have plaftform-spedific code in my package vignette:

x <- c("01JAN2020:00:00:00", "15JAN2020:00:00:00")
# This is plaftform-spedific
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)

Thomas
  • 457
  • 2
  • 12

1 Answers1

1

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.

Roland
  • 127,288
  • 10
  • 191
  • 288
  • Thank you! Since I am not the producer of the data, I cannot change the format. I used locale = "C". From `?Sys.setlocale`, '"C" (...) is the default for the C language and reflects North-American usage – also known as "POSIX"' – Thomas Jan 31 '22 at 14:18