[R] Correct Localized Numbers on Plots, related to glibc!

Majid Einian einian85 at gmail.com
Tue Jan 17 10:27:46 CET 2012


> You need to read ?Sys.setlocale (surely part of the homework the R posting guide asked of you).

I have read that. And I have used the standard way of changing locale
to fa_IR.utf8 (i.e. using
Sys.setlocale(category="LC_ALL",locale="fa_IR.utf8"). Also
Sys.setlocale(category="LC_NUMERIC",locale="fa_IR.utf8") )  The output
of Sys.localeconv at the end of my email should have made this clear.


> It is vital that you give the 'at a minimum' information requested in the posting guide when asking such questions, and we also absolutely need to know what graphics device you are trying to use.

The result is the same on RStudioGD, X11, pdf, ps, cairo_pdf,
cairo_ps, svg, png, jpeg, bmp. (I do not know if this is what you are
asking for. if not let me what exactly you are asking and how can  I
find it please.)
My sessionInfo is as follows:

R version 2.14.1 (2011-1-22)
Platform: i486-pc-linux-gnu (32 bit)

locale:
 [1]  LC_CTYPE=fa_IR.utf8			LC_NUMERIC=fa_IR.utf8
 [3]  LC_TIME=fa_IR.utf8				LC_COLLATE=fa_IR.utf8
 [5]  LC_MONETARY=fa_IR.utf8		LC_MESSAGES=en_US.UTF-8
 [7]  LC_PAPER=C					LC_NAME=C
 [9]  LC_ADDRESS=C				LC_TELEPHONE=C
[11]  LC_MEASURMENT=en_US.UTF-8	LC_IDENTIFICATION=C

attached base packages:
[1] stats	graphics	grDevices	utils	datasets	methods	base

loaded via a namespace (and not attached):
[1] tools_2.14.1

 I have read the posting guide. I had not posted the sessionInfo as
the information on system and graphic device seemed irrelevant, as it
does not change in different devices and also on Microsoft Windows
the locale Persian_Iran.1256 does not change anything. I have not
talked about windows as I don't expect windows to do anything
correctly on Persian.


>
> On 15/01/2012 08:26, Majid Einian wrote:
>>
>> Dear R Helpers,
>>
>> I want to localize my plots, i.e. the numbers by x&  y axis be
>>
>> Persian, using Persian numerals and Persian decimal separator. I
>> change the locale to fa_IR.utf8, but nothing on plots change. I can
>
>
> How, precisely?  Please show us exactly what you did, with a reproducible example.
>

Well, I assume that changing the locale should do the trick, but it
does not. As I mentioned earlier:
X11()
Sys.setlocale(category="LC_ALL",locale="fa_IR.utf8")
Sys.setlocale(category="LC_NUMERIC",locale="fa_IR.utf8")
plot(gdpr)

>
>> change the numerals shaping to Persian ones (۱۲۳۴ instead of 1234)
>> using some non-standard fonts but the decimal point is a problem. I
>> asked about that in Persian-Computing mailing list and I got the
>> answer that follows. I don't know how should I use this "l" flag
>> mentioned in the answer in R plots (I'm using simple R plots, no
>> special library).
>>
>> Has anybody had similar problem in any language (maybe Arabic, other
>> languages I'm not sure use different numeral characters).
>> Also I don't have e.g. French locale on my system to see if the
>> decimal separator changes accordingly to locale for them.
>
>
> It will if they followed the documentation.
>
>
>> Thanks in advance.
>>
>> -----------------------------------------------------------------------------
>>  Roozbeh Pournader<roozbeh at gmail.com>  Tue, Dec 6, 2011 at 3:47 AM
>> To: Majid Einian<einian85 at gmail.com>
>> Cc: persian-computing at googlegroups.com
>>
>> The glibc model for generating numbers is kind of complex. For using
>> native digits, one is supposed to use the "I" flag. For example, in
>> order to get ۱۲٫۳, you should do printf("%I.1f", 12.3).
>>
>> This is to make sure applications have a way to output both ASCII
>> numbers, and native numbers.
>>
>> Roozbeh
>>
>>
>
>
> --
> 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
>
> ______________________________________________
> R-help at r-project.org 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.




--
Majid Einian,
PhD Candidate in "Economics",
Graduate School of Management and Economics,
Sharif University of Technology,
Tehran, IRAN



More information about the R-help mailing list