I am trying to use Leaflet package in R to draw a amp and connect the markers given the latitude and longitude information in the table below.
| Observation
Depending on what the purpose of the lines is, another great option is gcIntermediate(). It outputs a CURVED SpatialLines object, based on the curvature of the earth. Not great for directions though. SpatialLines class objects work very well with Leaflet. See here for an excellent example. I've posted a modified form, that starts with the data frame from Paul Reiners.
library(leaflet)
library(geosphere)
mydf <- data.frame(InitialLat = c(62.469722,48.0975), # initial df
InitialLong = c(6.187194, 16.3108),
NewLat = c(51.4749, 51.4882),
NewLong = c(-0.221619, -0.302621))
p1 <- as.matrix(mydf[,c(2,1)]) # it's important to list lng before lat here
p2 <- as.matrix(mydf[,c(4,3)]) # and here
gcIntermediate(p1, p2,
n=100,
addStartEnd=TRUE,
sp=TRUE) %>%
leaflet() %>%
addTiles() %>%
addPolylines()