[R] dot - comma problem

may.ka38 at yahoo.de may.ka38 at yahoo.de
Sun May 20 15:52:39 CEST 2012


Dear all

I am trying to use the ODB package to connect to an libreoffice-odb database. 
The libreoffice package is german, thus, decimal separator is a comma. However, 
I can open the database and upload a it without error,

library(ODB)
db <- odb.open("Test.odb")

but a soon as the "odb.open" command is executed, the decimal separator in R 
is changed to comma.

Before loading the database:

> a <- 10.1
> a
[1] 10.1

After loading the database

> db <- odb.open("Buchhaltung.odb")
> a
[1] 10,1

but assigning a numeric value to a variable still requires a dot:

> a <- 5,1
Error: Unexpected ',' in "a <- 5,"

Futhermore, printed variables still use the comma as decimal separator:

> write.csv(a)
"","x"
"1",10,1

Since this leads to serious parsing errors when odb sets up sql-queries (eg 
5,1 becomes 51), I need to get rid of that behaviour such that numeric values 
are correctly displayed with a dot as a decimal separator.

Does anyone has an idea?

Thanks

Karl

Ps: The following does not work:

> a <- as.character(a)
> a
[1] "10,1"
> a <- sub(",",".",a)
> a
[1] "10.1"
> a <- as.numeric(a)
> a
[1] 10,1
>



More information about the R-help mailing list