I tried a row by row approach, like this:
library(geosphere)
best <- 1000000
for ( var1 in df1 )
{ findpoint <- c(df1$longitude[var1], df1$latitude[var1])
for ( var2 in df2 )
{ basepoint <- c(df2$longitude[var2], df2$latitude[var2])
dis <- distHaversine( basepoint, findpoint, 6378137)
if (dis < best) {best <- dis
}
print ( best)
}
and get "Error in .pointsToMatrix(p1) : Wrong length for a vector, should be 2"
I want to use an approach without any external functions so I can confirm the results from an approach using one. Of course I will actually be looking for the best 5 point and recording their info with the df1 data.