-此代码可以正常工作
FL.POP = read.csv("C:\\Users\\jevans\\Desktop\\Jessica School\\Florida population 2010-2019.csv", header = TRUE )
Year <- as.numeric(FL.POP$Year)
Population <- as.numeric(FL.POP$Population_Estimation)
model<-lm(Population~Year)
model
plot(formula=(Population~Year),data=FL.POP,main='Florida Population')
abline(reg=lm(formula=(Population~Year),data=FL.POP),col='red')
summary(FL.POP)
new.years<- data.frame(Year = c(2019,2020,2021,2022,2023,2024,2025))
NewData<-predict(model,newdata = new.years)
NewData
new.pop<- data.frame(Population = c(NewData))
new.pop
new.years
-我无法将新的预测和新的年份附加到我的原始数据中,以便我可以将其绘制出来。
尝试一下: