-5

In the nycflights13 package, how do I see all of the carriers in the carrier variable? I can pull up the list of variables from air_time to year, but I want to see the list of all the carriers. Please let me know!

bgcorbett95
  • 13
  • 1
  • 6

2 Answers2

1

The carriers are listed in the airlines data frame.

nycflights13::airlines
# # A tibble: 16 x 2
#    carrier name                       
#    <chr>   <chr>                      
#  1 9E      Endeavor Air Inc.          
#  2 AA      American Airlines Inc.     
#  3 AS      Alaska Airlines Inc.       
#  4 B6      JetBlue Airways            
#  5 DL      Delta Air Lines Inc.       
#  6 EV      ExpressJet Airlines Inc.   
#  7 F9      Frontier Airlines Inc.     
#  8 FL      AirTran Airways Corporation
#  9 HA      Hawaiian Airlines Inc.     
# 10 MQ      Envoy Air                  
# 11 OO      SkyWest Airlines Inc.      
# 12 UA      United Air Lines Inc.      
# 13 US      US Airways Inc.            
# 14 VX      Virgin America             
# 15 WN      Southwest Airlines Co.     
# 16 YV      Mesa Airlines Inc.  

Or am I not understanding the question?

David J. Bosak
  • 1,386
  • 12
  • 22
1

I presume you are looking at the 'flights' table in that package, since it contains a carrier variable.

For a list of the unique values in a variable, you could use base unique function:

unique(nycflights13::flights$carrier)
[1] "UA" "AA" "B6" "DL" "EV" "MQ" "US" "WN" "VX" "FL" "AS" "9E" "F9" "HA" "YV" "OO"

or table to count the number of appearances:

table(nycflights13::flights$carrier)
   9E    AA    AS    B6    DL    EV    F9    FL    HA    MQ    OO    UA    US    VX    WN    YV 
18460 32729   714 54635 48110 54173   685  3260   342 26397    32 58665 20536  5162 12275   601 
Jon Spring
  • 55,165
  • 4
  • 35
  • 53