Adding regression line to scatter plot can help reveal the relationship or association between the two numerical variables in the scatter plot. With ggplot2, we can add regression line using geom_smooth() function as another layer to scatter plot. In this
R makes it very easy to create a scatterplot and regression line using an lm object created by lm function. We will illustrate this using the hsb2 data file.
Often when we perform simple linear regression, we’re interested in creating a scatterplot to visualize the various combinations of x and y values.. Fortunately, R makes it easy to create scatterplots using the plot() function.
Post a Comment:
Showing 0 Comments: