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
What about the following loop over your api calls?
df$distance <- 0
for (i in nrow(df)){
drs <- df[i,]$departure
fue <- df[i,]$arrival
url <- paste0("https://airport.api.aero/airport/distance/", drs, "/", fue, "?user_key=4e816a2bf391f8379df1c42d2762069e")
api <- curl_fetch_memory(url)
text <- rawToChar(api$content)
distance <- as.numeric(gsub(',','',substr(text,regexpr('distance',text)+11,regexpr('units',text)-4)))
df[1,]$distance <- distance
}
df