These are the goals
Using the mtcars dataset head(mtcars)
plot a simple scatterplot & regression lines on the scatterplot.
x axis = wt , y axis = mpg
Color the scatter plots based on values in column
vs, vs=0 dots grey, vs=1 dots = red.Regression lines by group =
gear(3 regression lines)Color the regression lines based on values in column
am, am=0 regression line = blue, am=1 regression line = green.
My attempt so far .
Any suggestions on how to accomplish this is much appreciated. Thanks.
head(mtcars)
mtcars %>%
ggplot(aes(x=wt , y = mpg))+
geom_point(size=1, aes(color=vs)) +
geom_smooth(method=lm, se=FALSE, aes(group=gear))
