Trying to make a simple scatter plot on R studio. However, this is the error which comes up : Can’t add ggsave("Plot1.png")
to a <ggplot> object
Here is my code :
library(tidyverse)
data()
names(mpg)
mpg %>%
filter(hwy < 35) %>%
ggplot(aes(x=displ,
y=hwy,
colour = drv)) +
geom_point() +
geom_smooth(method = lm,
se = F) +
theme_minimal() +
ggsave(
"Plot1.png")
Please let me know as to what may be wrong here! thank you!
New contributor
Disha Jawadekar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1