Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The flights data set seen in class is available in the package nycflights 1 3 as a tibble. It contains on - time data for

The flights data set seen in class is available in the package nycflights13 as a tibble. It contains on-time
data for all flights that departed New York City via its three main airports throughout the whole year of
2013. The airport from which each flight departed is recorded in the origin column.
a) Load the tidyverse suite of packages, as well as the nycflights13 package and the flights data
therein.
b) Cancelled flights are defined as those for which no departure or arrival took place. Write code using
pipe operators and filter() to create a new data set flights2 which removes any rows with missing
values (i.e. NA entries) for the dep_delay or arr_delay variables (Hint: see ?is.na and use the "and"
operator & and the negation operator !).
c) Define the new variable gain as the difference between the departure delay and the arrival delay, the
new variable air_hour as the air_time variable re-expressed in hours, and the variable gain_per_hour
as the gain per air_hour. Write code using pipe operators and the functions mutate() and select()
which creates a new tibble called flights3 containing only the gain_per_hour and origin variables.
(Hint: you may exploit the fact that mutate() allows you to refer to variables you have just created).
d) The ggplot2 code below plots a kernel density estimate of the gain_per_hour for each origin airport.
However, it overplots all three estimated density curves on the one graph. Modify this code so that it
(i) partitions/facets the graph into a separate panel for each origin and (ii) produces histograms with
50 bins rather than density plots.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

.. V le equal to OC 29 od none of these answers O e 31

Answered: 1 week ago

Question

2. Be tactful, but dont avoid talking about tough issues.

Answered: 1 week ago

Question

Define procedural justice. How does that relate to unions?

Answered: 1 week ago