I am utilizing R to create a linear regression to predict population estimates increase. I created this code, however, I am receiving this error for the prediction. Does anyone have any insight on this? Thanks!
Estimates = read_excel("/Users/emily/Desktop/State_Population_Data_Clean.xlsx")
ggpairs(data=Estimates, columns=1:2, title = "Colorado Estimate")
fit_1 <- lm(PopEstYear ~ PopEstAmount, data = Estimates)
ggplot(data = Estimates, aes(x = PopEstYear, y = PopEstAmount)) +
- geom_point() +
- stat_smooth(method = "lm", formula = y~x, col = "dodgerblue3") +
- theme(panel.background = element_rect(fill = "white"),
- axis.line.x=element_line(),
- axis.line.y=element_line()) +
- ggtitle("Linear Model Fitted to Estimates")
predict(fit_1, data.frame(PopEstYear = 2021))
Error in eval(predvars, data, env) : object 'PopEstAmount' not found