I have a piece of code like this:
f<-expression("3"*"±"*"2"~"kg"*"\U00B7"*yr^-1)
I want to replace the 3 and 2 (arbitrarily chosen values) with mean and st. dev., which are calculated automatically, so that when I do something like
mean<-mean(df$a)
stdev<-st.dev(df$a)
f<-expression(mean*"±"*stdev~"kg"*"\U00B7"*yr^-1)
and then use the annotate() function in ggplot2, like
+annotate(
"text",
x=55,
y=43.2,
label=f,
parse=T
)
the Values of mean and stdev will be included in the annotation, rather than just the words "mean" and "stdev". Does anyone know how to resolve this, or perhaps a workaround? Thanks