I'm trying to get a superscript for units of my y-axis using plotmath expressions referenced in several posts. I've looked through threads on using expression and also here, but it just isn't working for me. Here's what I have so far:
ggplot(data.frame, aes(Region, Zmar_sh)) +
geom_boxplot() + xlab("Region") +
ylab(expression(paste("eelgrass shoot density", " (shoots/", expression(m[2])))) +
ggtitle(expression(paste(italic("Zostera marina")," shoot density in X Bay", sep = " ")))
The ggtitle expression works, but I'm still not getting my y axis to read "eelgrass shoot density (shoots/m2)" with the "2" as superscript. What am I missing?