Evening all, hoping someone can help. I've spent the evening messing around with the ggplot package, but for some reason, I cannot get a regression line to show up using geom_smooth!
I've included the code here, unfortunately, the terminal doesn't actually flag it as an error however which is part of the reason why I'm stumped! I've run it line by line and each line executes with no flags. The graph itself even appears without a hitch, just missing the regression line!
code:
library(ggplot2)
ScatterPlot <- ggplot(graph, aes (x= Specimen.date, y= Daily.lab.confirmed.cases)) + geom_point() + geom_smooth(method = lm) + theme(axis.text.x = element_text(angle=90))
ScatterPlot + ylim(0,5000) + labs(x = "Date") + labs(y = "Daily Cases")
output:
> ScatterPlot <- ggplot(graph, aes (x= Specimen.date, y= Daily.lab.confirmed.cases)) + geom_point() + geom_smooth(method = lm) + theme(axis.text.x = element_text(angle=90))
> ScatterPlot + ylim(0,5000) + labs(x = "Date") + labs(y = "Daily Cases")
geom_smooth()
using formula 'y ~ x'
I've also tried converting columns to numeric but that didn't seem to work either ( x = as.numeric(), y = as.numeric().
any suggestions!?
Thank you
Michael
method = "lm"
instead ofmethod = lm
– Allan Cameron