Reputation: 1
Maybe it is the most stupid question and it worked a million times for me, but my Ab line is just not visible in the graph. What am I doing wrong?
My code
plot =ggplot(data=NULL, aes(x= data$ï..Year, y= loggdp))+
geom_line(col="blue")+
geom_abline( slope=0.01994632, intercept=11.96591, col="red" )
And this is the graph I get
Upvotes: 0
Views: 234
Reputation: 19
This is because your x-axis plots a time-series variable, so having a slope doesn't make sense (i.e., what is a 1 unit change in a time-series variable?). To resolve this, you can create a dummy variable with values 1, 2, ..., n and plot geom_abline() against that.
Upvotes: -2
Reputation: 2242
Maybe because it's outside of the visible area. For x=2000
(year 2000), the slope and intercept you have passed result (roughly) in a value of 11.96 + 2000*0.02 = 51.96
which is not in the y-axis range in this plot.
Upvotes: 1