title: Distances between consecutive points
body: <p>I have a data frame with longitude and latitude data, and I want to calculate the distance between every consecutive points. </p>
  
  <p>I have found that <code>distm</code> from the geosphere package calculates the distance, but it requires as an input longitude/latitude (can be a vector of two numbers, a matrix of 2 columns (first one is longitude, second is latitude) or a <code>SpatialPoints*</code> object) from two successive points.</p>
  
  <pre><code>distm(x, y, fun=distHaversine)
  </code></pre>
  
  <p>How can I generate <code>x</code> and <code>y</code>?</p>
  
  <h2>Edit:</h2>
  
  <p>For @Josh O'Brien comment:</p>
  
  <p>pts</p>
  
  <pre><code>lon   lat
  
  30.5 -42.5  
  31.5 -42.5  
  32.5 -43.5  
  33.5 -43.5
  35.5 -43.5
  </code></pre>
  
  <p>I get </p>
  
  <p>segDists </p>
  
  <pre><code>82198.54  137803.62   80876.19  161749.47      
  </code></pre>