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

laurent lgautier at gmail.com
Sun Nov 16 17:25:25 CET 2008


That might also be reporting something that can be felt like a brittle
aspect of R when embedded.

I am very tempted to ask why enforcing LC_NUMERIC to "C" for the
whole process while this only concerns numerical values written into
"data" files. I am understanding that at least postscript/pdf files are
affected, and so might files representing R serialized objects.

Functions like glib's 'g_ascii_dtostr()/g_ascii_strtod()' appear to have
been developed for such purposes, for example.

L.

On Sun, 2008-11-16 at 12:40 +0000, Prof Brian Ripley wrote:
> 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.
> >>
> >
>



More information about the R-devel mailing list