'How to use annotate_figure function

Im trying to use the annotate_figure function to add a title to my graph. I'm currently running this code :

p3<- ggplot(SPPLongForm, aes ( x =Score, fill = Time))+
  geom_bar(position ="identity")+
  theme_classic()+
  scale_fill_manual(values = c("cadetblue4", "darkred"))+
  theme(legend.position="top") +
  theme(strip.text.x=element_blank())+
  scale_x_continuous (breaks = seq (1,7,1))+
  facet_grid(.~Time)+
  labs(x= "Mean Score", fill ="", y = "Count")


annotate_figure(p1, left=text_grob("Socially Prescribed Perfectionism Subscale"))+
  ggsave(file = "p1.png", p1, dpi = 700)

My graph runs correctly, but when I run the annotate_figure function I receive the warning "Error: Can't add e2 to a ggplot object." . I'm not sure what this error is telling me



Sources

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

Source: Stack Overflow

Solution Source