[R] Locale changed after an RODBC connection on Linux

François Morneau francois.morneau at ign.fr
Wed May 31 11:21:17 CEST 2017


Dear helpeRs,

When connecting to a PostgreSQL database (via the RODBC functions 
odbcConnect or odbcDriverConnect), my locale are redefined from:
  [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8
  [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8
  [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C

to:
[1] fr_FR.UTF-8

Loading RODBC does not affect the locale. It happens only after opening 
a first connection:

 > ch <- odbcConnect(dsn = "Inv_Exp")

After that the Sys.localeconv() is changed and among others, the 
"decimal_point" is modified from "." to ",", which as an impact on my R 
script which was previously running.

I am running an Linux Mint computer. The rest of my sessionInfo() is:

R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

other attached packages:
[1] RODBC_1.3-15

loaded via a namespace (and not attached):
[1] compiler_3.4.0

We observed the same behaviour on my colleague's computer (also on the 
same Linux Mint version) but not on Windows (7) or on a more recent 
Ubuntu 16 with sessionInfo() :

R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
  [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8
  [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8
  [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

other attached packages:
[1] RODBC_1.3-15

loaded via a namespace (and not attached):
[1] compiler_3.4.0

Going back to previous versions (even old ones) of RODBC does not solve 
the issue. I certainely miss something obvious but can not find out what.

Regards,

François Morneau



More information about the R-help mailing list