[R] Using Unicode inside R's expression() command
dwinsemius at comcast.net
Sun Nov 10 22:10:56 CET 2013
On Nov 9, 2013, at 11:01 AM, Sverre Stausland wrote:
> I'm using 'expression()' in R plots in order to get italicized text.
> But it appears as if I cannot use Unicode symbols inside 'expression'
> outside of ASCII characters. Is there some way I can work around this?
> My goal is to get the 'ﬁ' ligature in various labels in my R barplots
> (together with italicized text). I think I could work around this if
> there was another way of italicizing selected characters in a string
> than using 'expression()'.
> I'm using R for Windows version 3.0.2.
> CairoPDF(file = "Ligature1.pdf")
> text(x =.5, y = .5, labels = "ﬁ", family = "Times New Roman")
> CairoPDF(file = "Ligature2.pdf")
> text(x =.5, y = .5, labels = expression(paste(italic(m), "u", "ﬁ",
> italic(m), sep = "")), family = "Times New Roman")
To the list readers: I posted a comment to the identical SO question that changing the font with CairoFonts before the CairoPDF call might be more effective. (I used a font name of "TimesNewRoman" rather than "Times New Roman" but testing with
CairoFontMatch(fontpattern="Times New Roman",sort=FALSE,verbose=TRUE)
... proved that the spaces were not causing problems. I happen to have a copy of Times New Roman since I have purchased MS Office, but I do not know if everyone would have that font installed. )
# The default family is Helvetica on my machine running OSX 10.7.5
Alameda, CA, USA
More information about the R-help