title: Possible to replicate this in R?
body: <p>For this question, i have given just one <strong>CaseNo</strong> as an example. In my df, i have millions.</p>
  <p>Essentially what i want if the submission time is same for case no, the first row should equal one and all the other rows should equal 0 for that submission time, then for the submission time that is different, it should be 2 and so on.</p>
  <p>df</p>
  <pre><code>CaseNo&lt;-c(1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096)
  SubmissionTime&lt;-c(&quot;2019-12-06  2:06:59 PM&quot;,&quot;2019-12-06  2:06:59 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;)
  </code></pre>
  <p>What i want:</p>
  <pre><code>CaseNo&lt;-c(1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096,1834096)
  SubmissionTime&lt;-c(&quot;2019-12-06  2:06:59 PM&quot;,&quot;2019-12-06  2:06:59 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-08  2:18:54 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;,&quot;2020-05-12  7:25:03 PM&quot;)
  Rank&lt;-c(1,0,2,0,0,0,0,3,0,0,0)
  </code></pre>
  <p>For every new case, it should start from 1.</p>
  <p>Also, i have already arranged the df such that it goes from the oldest submissiontime to the most recent</p>
  <p>I was thinking a combination of dense_rank and/or rank using dplyr?</p>