I'd like to manually add a regression equation to a plot that includes the proper mathematical notation (e.g., italics, superscripts). Annotate() seems perfect for this, but it doesn't seem to accept the expression() function in the labels argument. Here is a simple example. The annotation with expression() in it won't display. What am I doing wrong?
library(ggplot2)
x <- 1:10
y <- x^2
df <- data.frame(x, y)
sp <- ggplot(df, aes(x, y)) + geom_point()
sp + annotate('text', label = expression('y = x^2'), x = 2.5, y = 50) +
annotate('text', label = 'y = x^2', x = 2.5, y = 75)