This question has been asked previously but never with the following arrangement of the data. Below is a sample of it:
> head(datagps)
   Date & Time [Local]  Latitude Longitude
1: 2018-06-18 03:01:00 -2.434901  34.85359
2: 2018-06-18 03:06:00 -2.434598  34.85387
3: 2018-06-18 03:08:00 -2.434726  34.85382
4: 2018-06-18 03:12:00 -2.434816  34.85371
5: 2018-06-18 03:16:00 -2.434613  34.85372
6: 2018-06-18 03:20:00 -2.434511  34.85376
As you can see, I've a Date & Time [Local] column where GPS positions are registered every 4 min on average. I would like to calculate the distance (in meters) between two consecutive recordings and store this measure in a new column Step. I've been trying to implement distm() to my data:
> datagps$Step<-distm(c(datagps$Longitude, datagps$Latitude), c(datagps$Longitude+1, datagps$Latitude+1), fun = distHaversine)
Error in .pointsToMatrix(x) : Wrong length for a vector, should be 2
Although I'm very unsure about the syntax and if this is the right way to fill the arguments of the function. I'm very new to R so I hope I can get some help.
Any input is appreciated!
 
     
     
    