1. In the mpg data set, which manufacturer produced the most fuel economic SUVs?

p1_data <- mpg %>%
  filter(class == "suv") %>%
  select(manufacturer, hwy, cty) %>%
  mutate(avg_mpg = (hwy+cty)/2)

ggplot(p1_data) +
  geom_boxplot(aes(manufacturer, avg_mpg)) +
  labs(title = "SUV Fuel Economy Data by Vehicle Manufacturer",
       x = "Manufacturer of SUVs",
       y = "Average Mile per Gallon") +
  theme(plot.title = element_text(hjust = 0.5))

Comments: Subaru produced the most fuel economy SUVs.

2. In the mpg data set, which SUV manufacturer improved fuel economy most between 1999 and 2008?

p2_data <- mpg %>%
  filter(class == "suv") %>%
  select(manufacturer, hwy, cty, year) %>%
  mutate(avg_mpg = (hwy+cty)/2)

ggplot(p2_data) +
  geom_boxplot(aes(as.factor(year), avg_mpg)) +
  facet_wrap(~ manufacturer) +
  labs(title = "SUV manufacturers fuel econmy improvment between 1999 and 2008",
       x = "Year",
       y = "Average MPG of SUVs") +
  theme(plot.title = element_text(hjust = 0.5, size = rel(1.3)))

Comment:The land rover has the most fuel economy improvment.

3. In the flights data set, pick up another variable other than carrier and analyze whether that variable correlates with long-delay flights or not. .

p3_delay <- flights %>%
  select(dep_delay, arr_delay, distance) %>%
  filter(!is.na(distance) & !is.na(dep_delay) & !is.na(arr_delay))

ggplot(p3_delay) +
  geom_bin2d(aes(dep_delay, distance), bins = 40) +
  labs(title = "Plot Of Departure Deplay Time And Flight Distance",
       x = "Departure Delay time",
       y = "Flight Distance (miles)") +
  theme(plot.title = element_text(hjust = 0.5, size = 15),
        axis.title = element_text(size = 12))

ggplot(p3_delay) +
  geom_bin2d(aes(arr_delay, distance), bins = 40) +
  labs(title = "Plot Of Departure Deplay Time And Flight Distance",
       x = "Arrive Delay time",
       y = "Flight Distance (miles)") +
  theme(plot.title = element_text(hjust = 0.5, size = 15),
        axis.title = element_text(size = 12))

Comment: Flight distance have no clear relationship with the departure delay time.