title: How to group by all variables except some and add a group id to every observation
body: <p>I have a data set like this:</p>
  
  <pre><code>data(CO2, package = 'datasets')
  
  ##    Plant        Type  Treatment conc uptake
  ## 1    Qn1      Quebec nonchilled   95   16.0
  ## 2    Qn1      Quebec nonchilled  175   30.4
  ## ... 
  ## 17   Qn3      Quebec nonchilled  250   40.3
  ## 18   Qn3      Quebec nonchilled  350   42.1
  ## ...
  ## 27   Qc1      Quebec    chilled  675   35.4
  ## 28   Qc1      Quebec    chilled 1000   38.7
  ## ...
  ## 36   Qc3      Quebec    chilled   95   15.1
  ## 37   Qc3      Quebec    chilled  175   21.0
  ## ...
  ## 47   Mn1 Mississippi nonchilled  500   30.9
  ##  ...
  ## 53   Mn2 Mississippi nonchilled  350   31.8
  ## 54   Mn2 Mississippi nonchilled  500   32.4
  ## ...
  ## 62   Mn3 Mississippi nonchilled  675   28.1
  ## 63   Mn3 Mississippi nonchilled 1000   27.8
  ## ...
  ## 70   Mc1 Mississippi    chilled 1000   21.9
  ## 71   Mc2 Mississippi    chilled   95    7.7
  ## 72   Mc2 Mississippi    chilled  175   11.4
  ## ...
  ## 83   Mc3 Mississippi    chilled  675   18.9
  ## 84   Mc3 Mississippi    chilled 1000   19.9
  </code></pre>
  
  <ul>
  <li>The observations shall be grouped according to the combination
  of <strong>all variables except</strong> <code>conc</code> and <code>uptake</code>. So I want to specify the 
  variables that I <em>don't</em> want to use for grouping</li>
  <li>I want to add a new variable <code>GroupID</code> to the data set, where all observations
  which belong to the same group have the same value of <code>GroupID</code></li>
  </ul>
  
  <p>I have found a working solution, however it is a behemoth:</p>
  
  <pre><code>library(dplyr)
  CO2 %&gt;% 
    mutate(GroupID=
           do.call( group_indices
                  , c( list(.data=.)
                     , colnames(.) %&gt;% 
                        setdiff(c('conc','uptake')) %&gt;% 
                        as.name()
                     )
                  )
           )
  
  ##    Plant        Type  Treatment conc uptake GroupID
  ## 1    Qn1      Quebec nonchilled   95   16.0       1
  ## 2    Qn1      Quebec nonchilled  175   30.4       1
  ## ...
  ## 8    Qn2      Quebec nonchilled   95   13.6       2
  ## 9    Qn2      Quebec nonchilled  175   27.3       2
  ## ...
  ## 15   Qn3      Quebec nonchilled   95   16.2       3
  ## 16   Qn3      Quebec nonchilled  175   32.4       3
  ## ...
  ## 22   Qc1      Quebec    chilled   95   14.2       4
  ## 23   Qc1      Quebec    chilled  175   24.1       4
  ## ...
  ## 29   Qc2      Quebec    chilled   95    9.3       6
  ## 30   Qc2      Quebec    chilled  175   27.3       6
  ## ...
  ## 36   Qc3      Quebec    chilled   95   15.1       5
  ## 37   Qc3      Quebec    chilled  175   21.0       5
  ## ...
  ## 43   Mn1 Mississippi nonchilled   95   10.6       9
  ## 44   Mn1 Mississippi nonchilled  175   19.2       9
  ## ...
  </code></pre>
  
  <p>Is there an easier solution?</p>
  
  <hr>
  
  <p><em>Bonus:</em> It would be a blast if there were a solution which would use all variables <em>of the same type</em> (e.g. all factor variables) for grouping.</p>