+.gg issue when trying to complete ggplot

Hi - I keep receiving the following error when trying to complete a ggplot:

Error in +.gg:
! Cannot use + with a single argument
:information_source: Did you accidentally put + on a new line?

I've included my code below:

install.packages("ggplot2")
require("ggplot2")
Plot.nocenter_interaction<-ggplot(data=final, aes(x=final$lifesat, y=final$edu, color=public))+
+geom_point()+
+geom_smooth(method = "lm", se = FALSE)+
+ylab("edu")+
+xlab("lifesat")+
+ggtitle("Life Satisfaction by Education [Public vs Private]")+
+theme_bw()

I've tried adding/removing the "+" in about every possible way and still no luck! Any help is much appreeciated.

Did you try something like this?

library(ggplot2)
Plot.nocenter_interaction <- ggplot(data=final, aes(x=lifesat, y=edu, color=public)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE) +
  ylab("edu") +
  xlab("lifesat") +
  ggtitle("Life Satisfaction by Education [Public vs Private]") +
  theme_bw()

This worked - thank you SO much!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.