title: Gather four columns with values in two keys
body: <p>Similar questions have been asked but they all refer to gathering multiple columns in one key column.</p>
  <p>I need multiple columns in two keys.</p>
  <p>This is the dataframe I have:</p>
  <pre>
  ID  ... measure_A.1 measure_A.2 measure_B.1 measure_B.2
  1       8.25        23.5        4       5
  2       8.6         22.5        3       4
  </pre>
  <p>If I use the following code I get this:</p>
  <pre><code> df %&gt;% 
   gather(key = measure_A, value = &quot;score_A&quot;, measure_A.1, measure_A.2) %&gt;%
   gather(key = measure_B, value = &quot;score_B&quot;, measure_B.1, measure_B.2)
  </code></pre>
  <pre> 
  ID  ... measure_A   score_A     measure_B   score_B
  1       measure_A.1 8.25        measure_B.1 4   
  1       measure_A.1 8.25        measure_B.1 4
  1       measure_A.2 23.5        measure_B.2 5
  1       measure_A.2 23.5        measure_B.2 5
  2       measure_A.1 8.6         measure_B.1 3
  2       measure_A.1 8.6         measure_B.1 3
  2       measure_A.2 22.5        measure_B.2 4
  2       measure_A.2 22.5        measure_B.2 4
  </pre>
  <p>what I want is this:</p>
  <pre>
  
  ID  ... measure_A   score_A     measure_B   score_B
  1       measure_A.1 8.25        measure_B.1 4   
  1       measure_A.2 23.5        measure_B.2 5
  2       measure_A.1 8.6         measure_B.1 3
  2       measure_A.2 22.5        measure_B.2 4
  </pre>
  <p>It seems to me, that i have to reduce something but i don't know how to do this in combination with the gather command. I found a solution with filter, but I don't understand how that works.</p>