I am attempting to pass an expression with subscript to a single geom_text()
label in ggplot
. Here is my code right now:
my_exp <- expression('my_exp'[s][u][b])
my_data <-
data.frame(
var_1 = c("a", "b", "c"),
var_2 = c(1, 2, 3)
)
my_data %>%
ggplot(aes(x = var_1, y = var_2))+
geom_text(aes(label = var_1))
Here is the resulting plot:
What I would like to do is replace the var_1
value of "a"
with the expression specified by my_exp
and then have geom_text()
evaluate that value as an expression, resulting in the subscript appearing on the ggplot.