title: r - gather multiple columns in multiple key columns with tidyr
body: <p>Not sure if <code>tidyr::gather</code> can be used to take multiple columns and merge them in multiple key columns. </p>
  
  <p>Similar questions have been asked but they all refer to gathering multiple columns in one key column. </p>
  
  <p>I'm trying to gather 4 columns into 2 key and 2 value columns like in the following example:</p>
  
  <p>Sample data:</p>
  
  <pre><code>df &lt;- data.frame(
      subject = c("a", "b"),
      age1 = c(33, 35),
      age2 = c(43, 45),
      weight1 = c(90, 67),
      weight2 = c(70, 87)
  )
  
    subject age1 age2 weight1 weight2
  1       a   33   43      90      70
  2       b   35   45      67      87
  </code></pre>
  
  <p>Desired result: </p>
  
  <pre><code>dfe &lt;- data.frame(
      subject = c("a", "a", "b", "b"),
      age = c("age1", "age2", "age1", "age2"),
      age_values = c(33, 43, 35, 45),
      weight = c("weight1", "weight2", "weight1", "weight2"),
      weight_values = c(90, 70, 67, 87)
  )
  
    subject  age age_values  weight weight_values
  1       a age1         33 weight1            90
  2       a age2         43 weight2            70
  3       b age1         35 weight1            67
  4       b age2         45 weight2            87
  </code></pre>