'Cannot add superscripts to facet label in ggplot

I cannot make the facet wrap for Rsquared have a 2 superscript. I know there are many questions about this but I have tried the suggestions and cannot make it work. Here is what I have:

my_labeller <- as_labeller(c( MAE = "MAE", RMSE = "RMSE", R2= "*R^2*",
                       default = label_parsed))

And then:

error %>% mutate(across(Metric, factor, levels=c("MAE" , "RMSE" , "R2"), labels = 
c("MAE" , "RMSE" , "R^2"))) %>%
ggplot(aes(x=Buffer, y=Value, group=Model))+
geom_line(aes(color=Model)) +
geom_point(aes(color=Model)) +
theme_bw() +
labs(y = "Value", x = bquote('Buffer radius (m)')) +
facet_wrap(~ Metric, nrow = 3, scales = "free_y", labeller=my_labeller)

But the graph still has R^2

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source