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

NOEL Yvonnick yvonnick.noel at uhb.fr
Wed Jan 24 20:08:58 CET 2007


Prof Brian Ripley a écrit :
> 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.)

Thanks for these helpful indications. This seems to be related to the 
RGtk2 package :

# Before loading RGtk2
 > as.numeric(".1")
[1] 0.1
 > as.numeric(",1")
[1] NA
Warning message:
NAs introduits lors de la conversion automatique
# After library loading
 > library("RGtk2")
 > as.numeric(".1")
[1] NA
Warning message:
NAs introduits lors de la conversion automatique
 > as.numeric(",1")
[1] 0,1

I send a copy of this post to the RGtk2 package maintainers.

Thanks for your help,

Yvonnick Noel, PhD.
Dpt of Psychology
U. of Rennes
France



More information about the R-help mailing list