Last active
February 15, 2016 04:14
-
-
Save sriyoda/01171d8d286a10fa2884 to your computer and use it in GitHub Desktop.
Connections Count
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
flights <- read.csv("flights (1).csv", stringsAsFactors = F) | |
airports <- read.csv("airports (1).csv", stringsAsFactors = F) | |
airports <- filter(airports, iata %in% union(flights$origin, flights$destination)) # subsetting airports by 1-1 matches | |
orig <- select(count(flights, origin), iata=origin, n1=n) #one-way from count | |
dest <- select(count(flights, destination), iata=destination, n2=n) #one-way two count | |
airports <- left_join(airports, select(mutate(left_join(orig, dest),tot=n1+n2),iata, tot)) %>% | |
filter(!is.na(tot)) # joining origin and destination airports for 1-1 matches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment