Let us continue with our topic of Linear Regression. In this section we would implement the linear regression using R. Please download the sample dataset to continue with the analysis. In this analysis we build a simple linear model predicting the salary of an employee based on number of years of experience. Let us start with implementation of linear regression in R.

Step 1: Set up a working directory. Setting up a working directory makes life very easy. We can refer to any file saved in working library without mentioning location again and again.

Step 2: Import the data set into R-Studio using following commands.

Step 3: Install the package required for Linear regression. We would install “caTools” for linear regression.

Step 4: build the linear regression model using the following command

Step 5: Summarize the output of regression model using the following command

Step 6: Predicting the regression output. In below command replace test_set with another sample data set. Basically we try test the regression results in the below command.

So, in the above mentioned 6 steps we could implement the very basic linear regression model using R.