title: How to recode a large number of repeated values in dataframe column
body: <p>I have a dataframe with ~34,000 rows. I have a identifier column containing ~2,300 unique values, that are repeated an arbitrary number of times for each value in this column.</p>
  <p>I need to recode these values into something shorter. So far, I can only find examples that show how to recode unique values manually, which isn't really practical in this case.</p>
  <pre><code>A tibble: 2300 × 1
  ID
  &lt;dbl&gt;
  24650010203
  24650010203
  24650010203
  24650010203
  24650010304
  24650010405
  24650010405
  24650010405
  24650010405
  24650010506
  etc...
  </code></pre>
  <p>What's the quickest and easiest way to recode all these values in a way that rows with the same identifier retain their identity? It can be something as simple as an integer range from 0001:2300, though I'd like all IDs to have the same number of digits.</p>
  <p>E.g.</p>
  <pre><code>24650010203 --&gt; 0001
  24650010203 --&gt; 0001
  24650010203 --&gt; 0001
  24650010203 --&gt; 0001
  24650010304 --&gt; 0002
  24650010405 --&gt; 0003
  24650010405 --&gt; 0003
  24650010405 --&gt; 0003
  24650010405 --&gt; 0003
  24650010506 --&gt; 0004
  </code></pre>