I want to subscript the '2' in 'NO2' in the main heading and the xlabel, and I want to add '(µg/m3)' (with a superscript '3') in the xlabel, but the way I did it before for histograms doesn't work. Any help would be gratefully received! This is what I have so far:
library(ggpubr)
ggdensity(bgbind$no2,
main = "Density plot of background NO2 concentrations",
xlab = "NO2")
You can just use the symbols directly:
A somewhat more portable way of doing this is using unicode escape sequences. I tend to do this by looking up, say, "unicode subscript 2" in a web search engine. This will usually give you the result in the format "U+AAAA" where "AAAA" is a four digit hexadecimal number. If you do
"\uAAAA"
as a string in R, this will be converted to the appropriate unicode symbol. So, for example, look at what prints in the console here: