I'm trying to create a plot with five variables, three of which are air pollutants: PM2.5, NO2, and O3. I want the numbers to be subscripts, which is how these are written in most literature, but I've been trying every variation I can think of using square brackets, expression(), bquote(), and others and nothing is working. This is the simplified code I have right now:
risks$variable <- factor(risks$variable,
levels=c("O3","PM2.5","NO2",
"Diethyl","Dimethyl"),
labels=c(expression(O[3]),
expression(PM[2.5]),
expression(NO[2]),
"Diethyl",
"Dimethyl"))
ggplot(risks, aes(variable, est, ymin = est - 1.96*sd,
ymax = est + 1.96*sd, col = q.fixed)) +
geom_pointrange(position = position_dodge(width = 0.75)) +
coord_flip()
Unfortunately, with everything I've tried the plot either shows the variable names with the square brackets around them, or the labels without brackets but the numbers still aren't subscripts. Any thoughts here?