title: How to renumber the observations based on the value of a column
body: <p>Below is the simplified example of my data, the column <code>new</code> is the one I want to add to the dataset. Basically, I want to rename the <code>riskset</code> using 1,2,3,4... so that it'll be easier for me to do loops. The numbers in <code>riskset</code> have been sorted, they are not continuous and there are duplicate numbers in the <code>riskset</code> (10~11 for each unique number), so how to add another column grouping the observations based on their <code>riskset</code> number?</p>
  
  <pre><code>  riskset            new
  a.0000000017          1
  a.0000000017          1
  a.0000000017          1
  a.0000000017          1
  a.0000000066          2
  a.0000000066          2
  a.0000000066          2
  a.0000000066          2
  a.0000000099          3
  a.0000000099          3
  a.0000000099          3
  a.0000000099          3
  a.0000000099          3
                ......
  </code></pre>