library(ggplot2)
library(tidyverse)
## ── Attaching packages ───────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble  2.1.3     ✓ dplyr   0.8.3
## ✓ tidyr   1.0.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ✓ purrr   0.3.3
## ── Conflicts ──────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
data(mpg)
#Q1
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy, color = class))

#Q2
ggplot(data = mpg, aes(x = displ, y =hwy)) +
  geom_point(mapping = aes(x = displ, y = hwy, color = class))+
  stat_smooth(method = 'lm')

#Q3
ggplot(data = mpg) +
  geom_point(data = mpg, mapping = aes(x = displ, y = hwy, color = drv)) +
  geom_smooth(
    mapping = aes(x = displ, y = hwy, linetype = drv),
    show.legend = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'