[R] RODBC: data base with decimal point ","

RINNER Heinrich HEINRICH.RINNER at tirol.gv.at
Fri Oct 22 08:53:43 CEST 2010


Dear R-users,

I am working with R version 2.10.1 and package RODBC Version: 1.3-2 under windows.

Say I have a table "testtable" (in an Access data base) with 3 columns and 1 row that looks like this:
X               Y       Z
0012345 42      42,1
The columns are of these types: X - character, Y - Long Integer, Z - Decimal.

I use RODBC to get these data into R:
> library(RODBC)
> channel <- odbcConnectAccess("C:\\temp\\testdb.mdb")
> x <- sqlFetch(channel, "testtable", as.is = TRUE) # need as.is so that X won't be converted to numeric
> summary(x)
      X                   Y           Z
 Length:1           Min.   :42   Length:1
 Class :character   1st Qu.:42   Class :character
 Mode  :character   Median :42   Mode  :character
                    Mean   :42
                    3rd Qu.:42
                    Max.   :42

So the problem seems to be the decimal point, as I am on an Austrian locale:
> Sys.getlocale()
[1] "LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252"

I tried
> options("dec")
$dec
decimal_point
          "."
> options(dec = ",")
, but that doesn't change anything.

How can I "tell" RODBC that the decimal point in my data base is ","?

Your advice would be appreciated;
kind regards
Heinrich.



More information about the R-help mailing list