I am trying to write LaTex formulas in ggplot titles and labels by using Tex
function from latex2exp
,
like
library(tidyverse)
library(latex2exp)
x = c(1,2,3)
y = c(10, 3, 2)
ggplot(data = data.frame(x = x, y = y), aes(x,y)) +
geom_point() +
labs(title = TeX("$s^2$"))
which results in
Error in str2expression(rendered): "could not find function "str2expression"
. How can I fix it?