Select and Mutate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hflights[c('ActualElapsedTime','ArrDelay','DepDelay')] | |
# Equivalently, using dplyr: | |
select(hflights, ActualElapsedTime, ArrDelay, DepDelay) | |
# Print out a tbl with the four columns of hflights related to delay | |
select(hflights, ActualElapsedTime, AirTime, ArrDelay, DepDelay) | |
# Print out hflights, nothing has changed! | |
hflights | |
# Print out the columns Origin up to Cancelled of hflights | |
select(hflights, Origin:Cancelled) | |
# Find the most concise way to select: columns Year up to and | |
# including DayOfWeek, columns ArrDelay up to and including Diverted | |
# Answer to last question: be concise! | |
# You may want to examine the order of hflight's column names before you | |
# begin with names() | |
names(hflights) | |
select(hflights, -(DepTime:AirTime)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment