Skip to content

Instantly share code, notes, and snippets.

@svenhofstede-zz
Created September 14, 2015 15:21
Show Gist options
  • Save svenhofstede-zz/06b18c62b34d1d85eab8 to your computer and use it in GitHub Desktop.
Save svenhofstede-zz/06b18c62b34d1d85eab8 to your computer and use it in GitHub Desktop.
for (i in 1:nrow(air)){
distance <- 999
lat_air <- air[i,"Latitude"]
long_air <- air[i,"Longitude"]
for(j in 1:nrow(subway)){
dist <- earth.dist(long_air,lat_air,subway[j,"Longitude"],subway[j,"Latitude"])
if(dist < distance){
distance <- dist
}
}
print(i)
flush.console()
air[i,"distSubway"] <- distance
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment