I am struggling because I am just trying to add my own x-axis values and tickmarks to a plot which shows also the linear regression.
It seems that OR I add the abline OR I add the axis. I can't do both!
Why?
Example data:
df = data.frame(year = c(1901:2000), total = ceiling(runif(100, 2, 3000)))
This code works ONLY for abline():
plot(df$year, df$total, xaxt='n')
abline(lm(df$total ~ df$year))
axis(1, at = seq(1,100, by = 10), labels = seq(1901, 2000, by = 10)) #this line does not work
This code works only for axis():
plot(df$total, xaxt='n')
abline(lm(df$total ~ df$year)) #this line does not work
axis(1, at = seq(1,100, by = 10), labels = seq(1901, 2000, by = 10))
Any help, please? thank you