My question is similar (basically the same) to the previous asked one: Draw All Lines Between Points
But I would like to have a solution using leaflet in R. Is it possible to do this using leaflet? The addPolylines()
function works as connecting all of the consecutive points in a dataframe. As the example dataset below, it is easy to connect all points by sequence, but how to draw all the possible segments between those five points?
I would like to see a general solution with leaflet that I can apply on scenarios with more points. Many thanks!
locations <- data.frame(Long = c(76,75,73,72,74,76), Lat = c(43,40,40,43,45,43))
leaflet("locations") %>%
addTiles() %>%
addPolylines(lng = locations$Long,
lat = locations$Lat)