2.2.7 An Introduction to Linear Regression - Video 4 Linear Regression in R
In our R Console, let's start by loading our data set. Don't forget to make sure you're in the directory containing the file wine.csv first. We'll call our data frame wine, and we'll use the read.csv function to read in the data file wine.csv. We can look at the structure of our data by using the str function. We can see that we have a data frame with 25 observations of seven different variables. Year gives the year the wine was produced, and it's just a unique identifier for each observation. Price is the dependent variable we're trying to predict. And WinterRain, AGST, HarvestRain, Age, and FrancePop are the independent variables we'll use to predict Price. We can also look at the statistical summary of our data using the summary function. This gives us information about the range of values for each variable in our data set. Let's now create a one-variable linear regression equation using AGST to predict Price. We'll call our regr...