[R] dot - comma problem

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun May 20 20:07:25 CEST 2012


Please report bugs in the ODB package (wherever that is from: you did 
not tell us) to its maintainer.

?Sys.setlocale will explain how to undo the damage.

On 20/05/2012 14:52, may.ka38 at yahoo.de wrote:
> 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
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list