I am trying to add text to a plot which includes both a variable and a greek letter. I would like to display the values that the variables pt and P_T take on but I'd like the greek letter to be used for alpha. The code below gives the following error:
Error in
f(): ! Aesthetics must be valid data columns. Problematic aesthetic(s): label = expression(...). Did you mistype the name of a data column or forget to add after_stat()?
Any help would be greatly appreciated!
x <- rep(seq(1,5),3)
value <- runif(15)
alpha <- rep(c(0.5,0.6,0.7),each=5)
my_data <- data.frame(x=x,value=value,alpha=alpha)
pt=6
P_T=0.7
ggplot(data=my_data, aes(x=x, y=value,group=as.factor(alpha),color=as.factor(alpha)))+
geom_line()+
scale_x_continuous(name =paste("True Landmark PFS at", pt, "Months"), breaks=seq(1,5,1))+
theme(plot.margin= unit(c(0.7, 0.7, 0.7,0.7), "cm"))+
theme(plot.title = element_text(hjust = 0.5, size=12))+
scale_y_continuous(name ="Probability of ESOE",breaks=seq(0,1,by=0.25),limits=c(0,1))+
guides(color = guide_legend(title = expression(alpha)))
geom_text(aes(x=3, label=expression(paste("Posterior prob (True RMST at",pt,"month>",alpha,"|data>",P_T)), y=0.75),
angle=0, size=2.5, color="black")
