0

I have a graph with 7 dots and I want to add trendline thanks for the help!

    percentage.no.work <- cleanData %>% group_by(AREA) %>%           
  summarise(percentage = mean(ESTIMATED.CITY.UNEMPLOYMENT))

ggplot() +
  geom_point(data=percentage.no.work, aes(x=AREA, y=percentage), alpha=0.6, color="purple", size=2) +
  geom_smooth(method = "lm") +
  theme_minimal() + ggtitle("Percentage Estimated City Unemployment") + 
  ylab("Percentage")
Quinten
  • 35,235
  • 5
  • 20
  • 53
Tal Itach
  • 41
  • 4
  • Could you please share some reproducible data using `dput`? So we can show you. – Quinten Jun 04 '22 at 08:44
  • 2
    Try with `ggplot(data=percentage.no.work, aes(x=AREA, y=percentage))`, i.e. make the data and aesthetics global. Otherwise the geom_smooth will not "see" the data and the mapping. – stefan Jun 04 '22 at 08:46
  • Like in this post: https://stackoverflow.com/questions/38412817/draw-a-trend-line-using-ggplot – Quinten Jun 04 '22 at 08:46

0 Answers0