[R] Degree symbol

Duncan Murdoch murdoch.duncan at gmail.com
Tue Mar 29 20:48:33 CEST 2011


On 29/03/2011 2:40 PM, stephen's mailinglist account wrote:
> I have been using both Windows and Linux versions of R so when I have
> opened files created in Windows I have found some issues in Linux. One
> was that my windows setup allowed me to enter a degree symbol from the
> keyboard for labelling axes.
> Now I have found that the following expression seems to work on both systems
>
> xlab = expression(paste("Temperature [",degree,"C]")),
>
> (I found this on someone's blog, but I forget who-- thank you whoever you are).
>
> Now my question is can I set up my Linux (ubuntu) system to recognise
> the degree symbol input from the keyboard, or for the sake of
> portability should I just go with the solution I have found?

The issue may be that your Linux system is using UTF-8 encodings, while 
your Windows one is using the Windows version of Latin1.  So if you tell 
R that your file is encoded in Latin1, it will likely work.  You can do 
this in the DESCRIPTION file for a package, or the "encoding" argument 
to source().

You can probably tell Ubuntu to use Latin1 for everything, but I would 
guess that's a bad idea.

Duncan Murdoch



More information about the R-help mailing list