title: TIme different counting group by id in R Programming
body: <p>Currently i tried:</p>
  
  <pre><code>bb &lt;- numeric(100)
  
  for(i in 2:10){bb[i]&lt;-try$start_HHMM[i]-try$end_HHMM[i-1]} // i want to use the 2nd start time to - 1st end time to get the interval timing.
  </code></pre>
  
  <p>From the script that I tried above , I can get the interval timing but it is not the same id.</p>
  
  <p>How can I put the condition in the script above to check the id?</p>
  
  <p><img src="https://i.stack.imgur.com/6jmTA.png" alt="enter image description here"></p>