I was wondering whether there was a way to compare airport distances(IATA codes). There are some scripts but not is using R. So I tried that with with the API:
developer
You can do this without an API, just using the co-ordinates of airports, which are available freely in a database here https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat
## Import airport data
airports <- read.csv("https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat", header = F)
library(geosphere)
## Calculate matrix of differences in km
distance.matrix <- distm(x = airports[,c("V8", "V7")], y = airports[,c("V8", "V7")])/1000
## This may take a while, and will generate a matrix 8107 by 8107, about 0.5gb in size.
## Rename dimensions to airport codes
rownames(distance.matrix) <- airports$V5
colnames(distance.matrix) <- airports$V5
## Example: km between Gatwick and Heathrow
distance.matrix["LGW", "LHR"]
[1] 41.24091