Re: [R] as.numeric(".1") + SessionInfo

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 24 Jan 2007 - 17:56:19 GMT

I can reproduce this via

> Sys.setlocale("LC_NUMERIC", "fr_FR")

[1] "fr_FR"
Warning message:
setting 'LC_NUMERIC' may cause R to function strangely in: setlocale(category, locale)
> as.numeric(",1")

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

[1] NA
Warning message:
NAs introduced by coercion

Assuming you have not done that anywhere, it should not happen. If you have, you were warned. (Have you tried starting R with --vanilla to be sure?)

as.numeric() is using strtod which should only be affected by the locale category LC_NUMERIC, and R itself does not set LC_NUMERIC. So either you or some rogue OS function must have, unless there is a pretty major bug in the OS. (Just using a UTF-8 fr_FR locale does not do it on either of the Linux variants I tried.)

On Wed, 24 Jan 2007, NOEL Yvonnick wrote:

>> >> as.numeric(",1")
>> NOEL> [1] 0,1
>> Instead of the output below, can you please give the full
>>
>> sessionInfo()
>>
>> output?
>
>
> Here it is:
>
> R version 2.4.0 (2006-10-03)
> i686-pc-linux-gnu
>
> locale:
> fr_FR.UTF-8
>
> attached base packages:
> [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
> [7] "base"

>
> other attached packages:
> lattice cairoDevice gWidgetsRGtk2 RGtk2 gWidgets
> "0.14-16" "1.2" "0.0-9" "2.8.6" "0.0-11"
>
> Yvonnick Noel, PhD.
> Dpt of Psychology
> U. of Rennes
> France
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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@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

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Thu Jan 25 15:57:48 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 Jan 2007 - 07:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.