forked from INFO-201/m9-dplyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise.R
44 lines (21 loc) · 1.23 KB
/
exercise.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Exercise 4: DPLYR and flights data
# Install the nycflights13 package and read it in. Require the dplyr package
# install.packages("nycflights13")
library(nycflights13)
library(dplyr)
# The data.frame flights should now be accessible to you. View it,
# and get some basic information about the number of rows/columns
# Add a column that is the amount of time gained in the air (`arr_delay` - `dep_delay`)
# Sort your data.frame desceding by the column you just created
# Try doing the last 2 steps in a single operation using the pipe operator
# Make a histogram of the amount of gain using the `hist` command
# On average, did flights gain or lose time?
# Create a data.frame that is of flights headed to seatac ('SEA'),
# On average, did flights to seatac gain or loose time?
### Bonus ###
# Write a function that allows you to specify an origin, a destination, and a column of interest
# that returns a data.frame of flights from the origin to the destination and only the column of interest
## Hint: see slides on standard evaluation
# Retireve the air_time column for flights from JFK to SEA
# What was the average air time of those flights (in hours)?
# What was the min/max average air time for the JFK to SEA flights?