The axis labels vary for a ggplot that I create within a function. Some of the labels have super/subscripts, while others don't. Example:
m.data <- data.frame(x = runif(10), y = runif(10))
x.labs <- c("rain, mm", "light*','~W~m^-2")
for (i in 1:2) {
ggplot(m.data, aes(x = x, y = y)) +
labs(title = bquote(.(x.labs[i])))
}
The title for the graph when i=2 is literally
light*','~W~m^-2
rather than the formatted version of same. With the same result, I also tried moving bquote inside each string.
x.labs <- c("bquote(rain*','~mm)", "bquote(light*','~W~m^-2)")
and
title = x.labs[i]
Of the many questions about ggplot and bquote, none seem to address passing in a symbol like the superscript indicator.