Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(dplyr)
- library(hflights)
- # Call both head() and summary() on hflights
- head(hflights)
- summary(hflights)
- # Convert the hflights data.frame into a hflights tbl
- hflights <- tbl_df(hflights)
- # Display the hflights tbl
- hflights
- # Create the object carriers, containing only the UniqueCarrier variable of hflights
- carriers <- hflights$UniqueCarrier
- # Use lut to translate the UniqueCarrier column of hflights and before doing so
- # glimpse hflights to see the UniqueCarrier variablle
- glimpse(hflights)
- lut <- c("AA" = "American", "AS" = "Alaska", "B6" = "JetBlue", "CO" = "Continental",
- "DL" = "Delta", "OO" = "SkyWest", "UA" = "United", "US" = "US_Airways",
- "WN" = "Southwest", "EV" = "Atlantic_Southeast", "F9" = "Frontier",
- "FL" = "AirTran", "MQ" = "American_Eagle", "XE" = "ExpressJet", "YV" = "Mesa")
- hflights$UniqueCarrier <- lut[hflights$UniqueCarrier]
- # Now glimpse hflights to see the change in the UniqueCarrier variable
- glimpse(hflights)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement