Module 1 Lesson 2 Application

Author

Jamal Rogers

Published

May 12, 2023

library(nycflights13)
library(tidyverse)

ggplot2 + dplyr

The relevant variables are:

  1. month, Date of departure
  2. carrier, Two letter carrier abbreviation
  3. air_time, Amount of time spent in the air, in minutes
  4. distance, Distance between airport, in miles
  5. 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")