title: Calculating distance between two GPS locations in a data frame using distm () in R
body: <p>This question has been asked previously but never with the following arrangement of the data. Below is a sample of it:</p>
  
  <pre><code>&gt; head(datagps)
     Date &amp; 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
  </code></pre>
  
  <p>As you can see, I've a <code>Date &amp; Time [Local]</code> 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 <code>Step</code>. I've been trying to implement <code>distm()</code> to my data:</p>
  
  <pre><code>&gt; datagps$Step&lt;-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
  </code></pre>
  
  <p>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.</p>
  
  <p>Any input is appreciated!</p>