How to draw multiple regression line in R

To create multiple regression lines in a single plot using ggplot2, we can use geom_jitter function along with geom_smooth function. The geom_smooth function will help us to different regression line with different colors and geom_jitter will differentiate the points.

Check out the below Example to understand how it can be done.

Example

Following snippet creates a sample data frame −

x1

Chủ Đề