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
Think this one is what you want:
install.packages("leaflet")
library(leaflet)
mydf <- data.frame(Observation = c("A", "B","C","D","E"),
InitialLat = c(62.469722,48.0975,36.84,50.834194,50.834194),
InitialLong = c(6.187194, 16.3108,-2.435278,4.298361,4.298361),
NewLat = c(51.4749, 51.4882,50.861822,54.9756,54.9756),
NewLong = c(-0.221619, -0.302621,-0.083278,-1.62179,-1.62179),
stringsAsFactors = FALSE)
mydf
Observation InitialLat InitialLong NewLat NewLong
1 A 62.46972 6.187194 51.47490 -0.221619
2 B 48.09750 16.310800 51.48820 -0.302621
3 C 36.84000 -2.435278 50.86182 -0.083278
4 D 50.83419 4.298361 54.97560 -1.621790
5 E 50.83419 4.298361 54.97560 -1.621790
m<-leaflet(data=mydf)%>%addTiles
for (i in 1:nrow(mydf))
m<-m%>%addPolylines(lat=c(mydf[i,]$InitialLat,mydf[i,]$NewLat),lng=c(mydf[i,]$InitialLong,mydf[i,]$NewLong))
And it shows: Network Connection using Leaflet