From ripley at stats.ox.ac.uk  Sun Nov 16 13:40:05 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sun, 16 Nov 2008 12:40:05 +0000 (GMT)
Subject: [Rd] problem with postscript/pdf plots, locales and embedded R
In-Reply-To: <1226771389.23719.14.camel@hot-spring>
References: <1226690614.8615.26.camel@hot-spring>
	<alpine.LFD.2.00.0811141932590.13635@gannet.stats.ox.ac.uk>
	<1226771389.23719.14.camel@hot-spring>
Message-ID: <alpine.LFD.2.00.0811152016160.21637@gannet.stats.ox.ac.uk>

You start from a false premise, and it seems that you are reporting a 
serious bug in Rpy to the wrong list:

   Note that R expects to be run with the locale category `LC_NUMERIC' set
   to its default value of C, and so should not be embedded into an
   application which changes that.

('Writing R Extensions').

On Sat, 15 Nov 2008, laurent wrote:

> Thanks for the quick answer.
>
> The documentation for Sys.setlocale mentions the possibility of warning
> when LC_NUMERIC is set.
>
> After checking it is looking like setting LC_NUMERIC from Sys.setlocale
> does issue a warning, but there is does not seem to be a warning when
> LC_NUMERIC is set in the parent shell. In the case the later is likely
> to cause trouble, would it be appropriate to issue a warning when R is
> initialized ?

Of course R does not violate its own documentation.  None of the R 
executables reset the LC_NUMERIC locale category, and all C programs start 
in the 'C' locale (both facts you should have known from the homework 
you did before posting).

BDR

>
>
> Laurent
>
>
>
> On Fri, 2008-11-14 at 19:37 +0000, Prof Brian Ripley wrote:
>> On Fri, 14 Nov 2008, laurent wrote:
>>
>>> Dear list,
>>>
>>> A problem with creating pdf or postscript plots from an embedded R, and
>>> in an environment where a locale is defined, was recently reported on
>>> the rpy (Python->R interface) mailing list.
>>>
>>> The problem appears to be that whenever the locale defines ',' as a
>>> separator for the decimal part of a numerical value, the pdf/ps file
>>> generated still has the ',' instead of a '.' causing problem when open
>>> the resulting file with a postscript/pdf viewer.
>>>
>>> Of course, an obvious workaround would be to force the locale for
>>> numbers to C ( LC_NUMERIC = "C" ), but that could be overriding
>>> internationalization features otherwise in R.
>>>
>>> Any advice ?
>>
>> Don't set LC_NUMERIC with R: ?Sys.setlocale did warn you about that.
>> It used to cause far more problems than this.
>>
>

-- 
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



[Rd] problem with postscript/pdf plots, locales and embedded R
Prof Brian Ripley