title: Assign numbers to groups in dplyr R
body: <p>Example data:</p>
  <pre><code>example_data &lt;-
    data.frame(value = c(1,3,4,6,7,8,4,6,9,0),
               group = c(&quot;Not applicable&quot;,
                         &quot;Large group&quot;,
                         &quot;Large group&quot;,
                         &quot;Not applicable&quot;,
                         &quot;Group of 1&quot;,
                         &quot;Group of 1&quot;,
                         &quot;Large group&quot;,
                         &quot;Large group&quot;,
                         &quot;Group of 1&quot;,
                         &quot;Not applicable&quot;))
  </code></pre>
  <p>I would like to assign group numbers, starting with 1, to groups, and zeroes to &quot;Not applicable&quot; values, preferably with <code>dplyr</code>.</p>
  <p>How do I assign the same group number to each Large group, but different numbers to each Group of 1?</p>
  <p>Desired output:</p>
  <pre><code>   value          group group_number
  1      1 Not applicable            0
  2      3    Large group            1
  3      4    Large group            1
  4      6 Not applicable            0
  5      7     Group of 1            2
  6      8     Group of 1            3
  7      4    Large group            4
  8      6    Large group            4
  9      9     Group of 1            5
  10     0 Not applicable            0
  </code></pre>
  <p>Solution from my previous <a href="https://stackoverflow.com/questions/73129976/create-runs-of-repeating-values-in-dplyr">question</a>:</p>
  <pre><code>example_data %&gt;%
    mutate(group_number = data.table::rleid(group)* (group != 'Not applicable'),
           group_number = dense_rank(group_number) - 1)
  </code></pre>
  <p>Gives me:</p>
  <pre><code>   value          group group_number
  1      1 Not applicable            0
  2      3    Large group            1
  3      4    Large group            1
  4      6 Not applicable            0
  5      7     Group of 1            2
  6      8     Group of 1            2
  7      4    Large group            3
  8      6    Large group            3
  9      9     Group of 1            4
  10     0 Not applicable            0
  </code></pre>
  <p>I would like each Group of 1 to have a different number.</p>