Question about unicode symbols in a R graphic

295 views
Skip to first unread message

Ivania Ceron Souza

unread,
Oct 23, 2012, 11:51:04 AM10/23/12
to stri-R...@googlegroups.com
Dear all!
I am constructing a graph in R and I want to show this expression in the Y axis: "Foliar δ15N (‰)"
I'm using the following code:
ylab=expression(paste("foliar ", delta ^{15},"N ", "(\u2030)"))

But it is not working because instead of the per mil symbol "‰" it appears the unicode "\u2030" in the parenthesis. 

The per mil symbol is written with U+2030  per mille sign (HTML: ‰ ‰)

I appreciate if some of you could teach me how to solve this problem.  

Thanks!

Ivania



Ivania Cerón Souza
Postdoctoral Fellow - Naos
Smithsonian Tropical Research Institute
Apartado 0843-03092
Panama, República de Panama
Tel: +(507) 212 8838
Fax: +(507) 212 8790

Marco Visser

unread,
Oct 24, 2012, 4:17:09 AM10/24/12
to stri-R...@googlegroups.com
Hi Ivania,

This fixes it on my linux machine (using a tilde ~);

plot(1:10,ylab=expression(paste("foliar ", delta ^{15},"N " ~"(\u2030)")))

Hope this helps,

Marco Visser

Marco Visser

unread,
Oct 24, 2012, 4:23:43 AM10/24/12
to stri-R...@googlegroups.com
Just a quick note; your original expression(paste("foliar
",delta^{15},"N ", "(\u2030)")) works fine in a windows virtual machine.
Which makes me think that your problem may be specific to your machine.
What platform are you using?

Marco

On 10/24/2012 10:17 AM, Marco Visser wrote:
> expression(paste("foliar ",delta^{15},"N ", "(\u2030)"))

Ivania Ceron Souza

unread,
Oct 24, 2012, 9:17:06 AM10/24/12
to stri-R...@googlegroups.com
Hi Marco
Thanks for your help.  I'm using mac...and yes, yesterday another person told me exactly the same, that my script run well in Linux.  It seems that I have to configurate my mac for UTF-8, but I don't sure how to do that.  Any clue?

Thanks!

Ivania

Ivania Cerón Souza
Postdoctoral Fellow - Naos
Smithsonian Tropical Research Institute
Apartado 0843-03092
Panama, República de Panama
Tel: +(507) 212 8838
Fax: +(507) 212 8790


Stuart Dennis

unread,
Oct 26, 2012, 1:50:54 PM10/26/12
to stri-R...@googlegroups.com
Hi Ivania (and Marco)
I thought I'd weigh in on this...
The problem isn't with your mac, its R. Specifically the language set that R is using  (your expression code works on my mac)
 Are you using a spanish installation of R? if so it might not be set up for UTF-8.
You can find out what the R system locale is by entering

Sys.getlocale()

for UTF-8 encoding to function it will need to see something like  "en_GB.UTF-8" - this one is for english (Great Britain)  or "de_DE.UTF-8" - german in Germany.

based on that logic yours "might" work if you append .UTF-8 to your current language and country locale code.
you can change it using
Sys.setlocale(category="LC_ALL", locale="...")

NOTE:  I dont know what would happen if you specify an invalid locale....you might have to reinstall R if it totally screws things up, or other things unique to a non-english locale night get broken.

hope that helps

stu

Ivania Ceron Souza

unread,
Oct 26, 2012, 3:32:18 PM10/26/12
to stri-R...@googlegroups.com
Dear Stuart
Thanks for your suggestion.  I just solved my problem.  My system local in R is English, so I set R to en_US.UTF-8 and now "magically" the Y-axis of my graphic has the ‰ symbol.

Thanks a lot for your help!  
(Also many thanks to Marco and Maya)

Ivania 



Ivania Cerón Souza
Postdoctoral Fellow - Naos
Smithsonian Tropical Research Institute
Apartado 0843-03092
Panama, República de Panama
Tel: +(507) 212 8838
Fax: +(507) 212 8790


Reply all
Reply to author
Forward
0 new messages