title: Time difference with day jump (midnight)
body: <p>I am trying to calculate the time differences between two consecutive observerations in data.frame called temp. I have both the time and the date:</p>
  
  <pre><code>           id version       date     time
  872169 261986       0 2012-01-13 24:24:34
  872170 262026       0 2012-01-13 24:26:11
  872171 262037       0 2012-01-13 00:02:46
  872172 262053       0 2012-01-14 00:10:28
  872173 262074       0 2012-01-14 00:28:42
  872174 262090       0 2012-01-15 14:29:31
  </code></pre>
  
  <p>Class of the time vector is of course <code>times</code>.
  Now I can create a vector containing the the differences:</p>
  
  <p>count &lt;- as.difftime(temp[,6], units="mins")</p>
  
  <p>But how do I account for the days? I tried several things: I combined the date and the time vector:</p>
  
  <pre><code>as.difftime(paste(temp[,4], temp[,6]), unit="min")
  </code></pre>
  
  <p>but this only gives me NA's.</p>
  
  <p>Also</p>
  
  <pre><code>as.difftime(strptime( paste(temp[,4], temp[,6]), "%Y-%m-%d %H:%M:%S"), unit="mins")
  </code></pre>
  
  <p>didn't work. </p>
  
  <p><code>difftime()</code> also doesn't work doesnt work since the dates aren't in two distinct vectors. I could think of copying the date vector and shifting it upwards so that the first value of the second date vector is the second element of the first date vector. But there must be something smarter.</p>
  
  <p>Thanks in advance!</p>