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

From: NOEL Yvonnick <yvonnick.noel_at_uhb.fr>
Date: Wed 24 Jan 2007 - 19:08:58 GMT

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



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 18:23:03 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 - 08: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.