[Rd] R CMD check: Locale not set to C?

Tobias Setz tobias.setz at rmetrics.org
Tue Feb 3 11:08:29 CET 2015


I just wanted to share my findings on this topic with you:

Custom variables for checking and building can be set through
"~/.R/check.Renviron" and " ~/.R/build.Renviron". But not the "LANGUAGE"
variable; it will always be set to "C". I couldn't find a way to change the
locales for a check or build run; they are always set to the locales of my
system ("German" in my case). Except the collation locale ("LC_COLLATE ")
which is set to "C". That is also what the manual mentions. This should
answer the question in the title.

Therefore I assume that generally the environment variables and the locales
should be set correctly by the package developers within the test (or
vignettes) files. And that it is not possible (or at least intended) to set
a custom language/location environment for build and check runs.


> Dear All
> 
> The "R CMD check" on the "zoo" (1.7-11) package results in an error on my
> environment. It can be reduced to the following example:
> 
> ----------------------------------------------------
> > require(zoo)
> > read.zoo(system.file("doc", "demo1.txt", package = "zoo"), sep = "|",
> format="%d %b %Y")
> 
> Error in read.zoo(system.file("doc", "demo1.txt", package = "zoo"), sep =
> "|",  :
>   index has bad entries at data rows: 14 15 16 17 18 19 20
> ----------------------------------------------------
> 
> I am using the following environment (on Windows 7):
> 
> ----------------------------------------------------
> > sessionInfo()
> R version 3.1.2 (2014-10-31)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> 
> locale:
> [1] LC_COLLATE=German_Switzerland.1252
> LC_CTYPE=German_Switzerland.1252 [3]
> LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C [5]
> LC_TIME=German_Switzerland.1252
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> ----------------------------------------------------
> 
> The problem are the locale settings. In the "demo1.txt" the months are
> abbreviated in English; while my environment would only accept German
> abbreviations. The problem can be solved by setting the time locale:
> 
> > Sys.setlocale("LC_TIME", "English")
> or
> > Sys.setlocale("LC_TIME", "C")
> 
> 
> Now; for "R CMD check", the manual
> (http://cran.r-project.org/doc/manuals/r-release/R-exts.html) states the
> following:
> 
> - "R CMD check and R CMD build run R processes with --vanilla..."
> So no possibility to set the locales (in contrary to the environment
> variables) through an "Rprofile" file...
> 
> - "All these tests are run with collation set to the C locale..."
> If I set "LC_ALL" or only "LC_TIME" to "C" the example shown at the top
> actually works if I run it manually.
> 
> 
> However; if I run "R CMD check" I get the ERROR.
> Therefore; are the locales really set to "C" for "R CMD check"?
> If yes; why would the example above not work?
> If no; how could I achieve custom locale settings?
> 
> Thanks!
> Tobias
> 
> 
> 
> ------------------------------------------
> Tobias Setz
> 
> Rmetrics Association
> tobias.setz at rmetrics.org
> www.rmetrics.org
>



More information about the R-devel mailing list