Question: To create a new data frame that includes flights headed to SFO in February, we first need to filter the flights data frame using the
To create a new data frame that includes flights headed to SFO in February, we first need to filter the flights data frame using the following criteria:
Destination airport is SFO
Flights take place in February
We can use the filter function from the dplyr package to achieve this.
The code would look like this:
r
librarydplyr
sfofebflights filterflights month dest "SFO"
This code creates a new data frame called sfofebflights that includes flights headed to SFO in February.
To determine how many flights meet these criteria, we can use the nrow function to count the number of rows in sfofebflights:
r
nrowsfofebflights
This returns the number of rows ie the number of flights in sfofebflights, which is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
