library(nycflights13)
library(tidyverse)Module 1 Lesson 2 Application
ggplot2 + dplyr
The relevant variables are:
- month, Date of departure
- carrier, Two letter carrier abbreviation
- air_time, Amount of time spent in the air, in minutes
- distance, Distance between airport, in miles
- arr_delay, arrival delays, in minutes
flights |>
filter(month %in% c(1,9) & carrier %in% c("DL", "EV", "UA")) |>
mutate(speed = distance / air_time) |>
na.omit() |>
ggplot() +
geom_point(mapping = aes(x = speed, y = arr_delay, col = carrier)) +
facet_wrap(~carrier) +
labs(
title = "New York City Flights 2013",
subtitle = "for DL, EV, and UA Carriers in January and September",
x = "speed in miles/minute",
y = "arrival delay in minutes"
) +
scale_color_manual(values = c("blue3", "green3", "violet"))ggsave("application2.png")