0

This is the code that I have so far and below is the plot that it has produced so far. Please, can someone tell me how I add the regression line?

ggplot(median.ppb, aes(x = postcode, y = medianppb)) +
geom_bar(stat = "identity") +
scale_x_discrete(limits = as.character(median.ppb$postcode)) + xlab("Postcode") + 
ylab("Median Price Per Bedroom in GBP (£)") + 
geom_text(label=medianprice)

enter image description here

N. berouain
  • 1,053
  • 13
  • 17
  • It's a bit hard to tell what you're doing and I'm sure one of the mods is going to tell you to produce a minimal reproducible example. I'm guessing you have only a simple linear regression here with price as a function of postcode? If so, you could extract the coefficients and use `geom_abline`. – svenhalvorson Jan 08 '20 at 13:20
  • What regression? Please, provide data. Try dput() – cmirian Jan 08 '20 at 14:38
  • To complete previous comments, see here for how to add a reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – dc37 Jan 08 '20 at 15:09
  • Please see this [link](https://stackoverflow.com/questions/58911673/fail-to-add-linear-regression-line-in-barplot) – Mohamed Rahouma Jul 08 '20 at 16:33

0 Answers0