suv <- filter(mpg, class == "suv")
suv1 <- select(suv,hwy, cty, manufacturer, year)
arrange(suv1,desc( hwy), desc( cty))
## # A tibble: 62 Ă— 4
## hwy cty manufacturer year
## <int> <int> <chr> <int>
## 1 27 20 subaru 2008
## 2 26 20 subaru 2008
## 3 25 19 subaru 2008
## 4 25 18 subaru 1999
## 5 24 18 subaru 1999
## 6 23 18 subaru 2008
## 7 22 17 jeep 2008
## 8 20 16 toyota 1999
## 9 20 16 toyota 2008
## 10 20 15 jeep 1999
## # ℹ 52 more rows
ggplot(data = suv1) +
geom_col(mapping = aes(x = manufacturer, y = hwy))
The most fuel economic SUVs are produced by Ford.
suv2 <- filter(suv1, between(year, 1999,2008))
ggplot(data = suv1) +
geom_col(mapping = aes(x = manufacturer, y = hwy, fill = year))
Subaru is the SUV manufacturer that improved fuel economy most between 1999 and 2008
flights1 <- select(flights, sched_dep_time, dep_delay)
flights2 <- filter(flights1, !is.na(dep_delay))
ggplot(flights2) +
geom_point(aes(sched_dep_time, dep_delay))
Based on the plot, the data seems to be uniform, so that the schedule departure time doesn’t seem to be related to the delay reason. But actually, we can tell most of the early morning flight - 5 am or late night flight- 11pm both has a small amount of delay compare to the other.