Unicode character with index

I want to add the Unicode character, which has two letters as indices for my plot legend in R. The symbol is r with an accent (Ε™), and the two letters are me and j.

I already examined this question: a Unicode superscript character and tried to adapt the answers to my problem.

Here is what I tried:

plot(1,pch=NA,ylab="",xlab="",axes=F) legend("top",legend=paste("1-","\u{0159}"),bty ="n",bg = "white",cex=2) legend("center",legend=paste("1-","\u{0159}","\u{0069}","\u{006A}"),bty="n",bg = "white",cex=2) legend("bottomleft",legend=expression("1-"*"\u0159"["\u0069"*"\u006A"]),bty="n",bg = "white",cex=2) legend("bottomright", legend = quote("1-" *"\u0159"["\u0069"*"\u006A"]),bty="n",bg = "white",cex=2) 

The resulting chart can be found below.

enter image description here

Both Unicode letter and index work on their own, but not together. paste () with any combination of [] returns an error, but I think this should be expected, since the insert cannot handle [] for indexes.

The CRAN FAQ site may give a hint since I am using Windows, but I am not sure how to implement this:

3.6 I do not see characters with accents on the R console, for example, in the text.

You need to specify a font in Rconsole (see Q5.2) that supports the encoding used. This used to be a problem in earlier versions of Windows, but now it's hard to find a font that doesn't.

The support for these characters in Rterm depends on the environment (the terminal and shell windows, including the locale and code page settings) in which it is running, as well as the font used in the terminal window. Usually they are in legacy DOS settings and need to be changed.

+7
r unicode plotmath
source share
1 answer

This refers to the language of the system, as can be seen, for example, if you try

 # intToUtf8(345) # [1] "Ε™" # iconv(intToUtf8(345), "utf-8", localeToCharset()) # [1] "r" 

This should fix (I used Czech, but maybe other locales too):

 Sys.setlocale("LC_CTYPE", "czech") # [1] "Czech_Czech Republic.1250" text(..., labels = quote("\u{0159}"[ij])) 
+3
source share

All Articles