Classwork 6

Data Transformatio with dplyr

Author

Byeong-Hak Choe

Published

February 11, 2026

Modified

February 16, 2026

R Packages

For Classwork 6, please load the following R packages and :

# install.packages("nycflights13")
library(ggthemes)
library(tidyverse)

Questions 1-9

Create the data.frame nycflights13::flights.

flights <- nycflights13::flights


Question 1

Find all flights that

  • Had an arrival delay of two or more hours
  • Flew to Houston (IAH or HOU)
  • Were operated by United (UA), American (AA), or Delta (DL)
  • Departed in summer (July, August, and September)
  • Arrived more than two hours late, but didn’t leave late
  • Were delayed by at least an hour for the depature, but reduced the delay over 30 minutes during flight
  • Departed between midnight and 6am (inclusive)



Question 2

How could you use arrange() to sort all missing values to the start?



Question 3

Brainstorm as many ways as possible to select dep_time, dep_delay, arr_time, and arr_delay from flights.



Question 4

  • Find the 10 most delayed flights using a ranking function.
    • How do you want to handle ties?



Question 5

Which carrier has the worst arrival delays within each origin airport?



Question 6

Which plane (tailnum) has the worst on-time arrival record?



Question 7

What time of day should you fly if you want to avoid delays as much as possible?



Question 8

For each destination, compute the total minutes of delay. For each flight, compute the proportion of the total delay for its destination.



Question 9

Find all destinations that are flown by at least two carriers. Use that information to rank the carriers.



Questions 10-11

Consider the tech_stocks data.frame.

tech_stocks <- read_csv(
  "https://bcdanl.github.io/data/tech_stocks_2015_2024.csv"
)


Question 10

For each Ticker, compute the daily stock return as the percent change in the Close price from the previous trading day to the current day.



Question 11

Provide a ggplot showing the relationship between daily stock return and daily trading volume (Volume) for each company (Ticker), and write a brief comment describing any visible pattern (e.g., positive/negative association, strength, outliers, and whether it differs across tickers).



Discussion

Welcome to our Classwork 6 Discussion Board! πŸ‘‹

This space is designed for you to engage with your classmates about the material covered in Classwork 6.

Whether you are looking to delve deeper into the content, share insights, or have questions about the content, this is the perfect place for you.

If you have any specific questions for Byeong-Hak (@bcdanl) regarding the Classwork 6 materials or need clarification on any points, don’t hesitate to ask here.

All comments will be stored here.

Let’s collaborate and learn from each other!

Back to top