I want to use the infinity sign on the x-axis of a box plot in R, which I want to write to a PDF file.
I can set the infinity symbol by doing
names(data)[9] <- "∞"
but that gets me encoding errors when trying to write:
conversion failure on '∞' in 'mbcsToSbcs': dot substituted for <...>
You can either use Unicode as in this example: using Unicode 'dingbat-like' glyphs in R graphics, across devices & platforms, especially PDF (infinity is Unicode 8734): in particular, it's possible that simply using a cairoPDF
device will make this work. Probably a better idea is to use ?plotmath
capabilities (as referenced in ?boxplot
under the names
argument:
boxplot(matrix(1:10,ncol=2),names=c("a",expression(infinity)))