Check the Linear regression introduction and how to use excel for linear regression.
In this post, let me explain how to use R programming for linear regression.
I am taking the same dataset in R to produce the linear regression.
Run the below codes.
Year<- c(2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010)
SalesAmount<-c(1450,1486,1560,1200,1205,1100,1150,1750,1650,1500,1900)
#linear regression
result<-lm(SalesAmount~Year)
#display coefficient
result
# new value for year 2011
year2011 <- data.frame(Year=2011)
year2011
#predict the sales amount.
predict (result,year2011)
About the Author