How to do a linear regression in R
Now that we have the model, we can visualize it by overlaying it over the original training data. To do this, we'll extract the slope and intercept from the model object and then plot the line over the training data using ggplot2. As you look at this, remember what we're actually doing here. We took a training dataset and used lm() to compute the best fit line through those training data points. Ultimately, this yields a slope and intercept that enable us to draw a line of the form .
Dec-4-2021, 04:55:45 GMT
- Technology: