I have a data frame with 6 columns:
- location id 1
- latitude 1
- longitude 1
- location id 2
- latitude 2
- longitude 2
I would like to calculate the distance between each of the 2 points in miles and add it as a new column. I'm struggling to find a function that does this. The closest I found is here: https://blog.exploratory.io/calculating-distances-between-two-geo-coded-locations-358e65fcafae but it fails because it can't find a function called 'list_extract
'.
Here's a sample of the data:
structure(list(df1_location_number = c(5051, 5051, 5051, 5051,
5051), df1_Latitude = c(34.7171375, 34.7171375, 34.7171375, 34.7171375,
34.7171375), df1_Longitude = c(-118.9107316, -118.9107316, -118.9107316,
-118.9107316, -118.9107316), df2_location_number = c(3051, 3085,
3022, 3041, 3104), df2_Latitude = c(34.7171375, 39.53404, 31.626788,
35.247982, 39.33425), df2_Longitude = c(-118.9107316, -93.292373,
-88.330116, -84.804119, -123.713064)), row.names = c(NA, 5L), class = "data.frame")
Any suggestions?