library(tidyverse)
library(nycflights13)
flights <- flightsClasswork 6
Data Transformation with R
Part 1. filter(), arrange(), and distinct()
For Part 1, consider the nycflights13::flights data.frame.
For detailed descriptions of the variables in this data frame, load its help documentation using the following command:
# Documentation for the `flights` data.frame from the `nycflights13` package
?flights # displays the description of variables in the `flights` data.frameQuestion 1
- Find all flights that had an arrival delay of two or more hours.
- Find all flights that flew to Houston (IAH or HOU).
- Find all flights that departed in summer (July, August, and September).
- Find all flights that arrived more than two hours late, but did not leave late.
Answer:
Question 2
- How many flights have a missing
dep_time?
Answer:
Question 3
- Sort flights to find the most delayed flights.
Answer:
Question 4
- Was there a flight on every day of 2013?
Answer:
Part 2. select() and rename()
Consider the following data.frame, nyc_payroll_new.
library(tidyverse)
nyc_payroll_new <- read_csv("https://bcdanl.github.io/data/nyc_payroll_2024.csv")For detailed descriptions of the variables in this data.frame, please refer to the following link:
Question 1
Create a new data.frame, df that keeps only the following five variablesβFiscal_Year, Agency_Name, First_Name, Last_Name, and Base_Salaryβfrom the data.frame nyc_payroll_new.
Answer:
Question 2
Given the data.frame df with a variable named Agency_Name, how would you rename it to Agency?
Answer:
Question 3
How would you remove the Fiscal_Year variable using select()?
Answer:
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) or peer classmate (@GitHub-Username) regarding the Classwork 6 materials or need clarification on any points, donβt hesitate to ask here.
Letβs collaborate and learn from each other!