[R] as.numeric(".1")

Martin Maechler maechler at stat.math.ethz.ch
Wed Jan 24 17:57:01 CET 2007

>>>>> "NOEL" == NOEL Yvonnick <yvonnick.noel at uhb.fr>
>>>>>     on Wed, 24 Jan 2007 17:29:14 +0100 writes:

    NOEL> Hello,
    NOEL> I noticed the following strange behavior under R-2.4.0 (Linux Mandriva 
    NOEL> 2007) :

    >> options("OutDec")
    NOEL> $OutDec
    NOEL> [1] "."

    >> as.numeric(".1")
    NOEL> [1] NA
    NOEL> Warning message:
    NOEL> NAs introduits lors de la conversion automatique

    >> as.numeric(",1")
    NOEL> [1] 0,1

Oops !  Should not happen, given your  getOption("OutDec") 

    NOEL> So I need to use the comma as the decimal separator,
    NOEL> at least as input.  Moreover, the last output also use
    NOEL> a comma, though the OutDec option was set to
    NOEL> ".". Basic arithmetic ops on the command line work OK
    NOEL> with decimal dots.

    NOEL> I am pretty sure as.numeric(".1") used to work under older versions of 
    NOEL> R.  Could it be a localization problem ?

maybe / probably.  We cannot easily reproduce.
Instead of the output below, can you please give the full



    NOEL> I would like to use the dot as the decimal separator
    NOEL> both for input and output.

Well definitely!  (Using "," is crazyness in my eyes!!)

    NOEL> Any suggestion ?

    NOEL> Thank you very much in advance,

    NOEL> Yvonnick Noel
    NOEL> Dprt of Psychology
    NOEL> U. of Rennes
    NOEL> France

    NOEL> platform       i686-pc-linux-gnu
    NOEL> arch           i686
    NOEL> os             linux-gnu
    NOEL> system         i686, linux-gnu
    NOEL> status
    NOEL> major          2
    NOEL> minor          4.0
    NOEL> year           2006
    NOEL> month          10
    NOEL> day            03
    NOEL> svn rev        39566
    NOEL> language       R

More information about the R-help mailing list