title: How to switch these columns and rows in R data frame?
body: <p>Suppose we have this data frame:</p>
  <pre><code>avg_1 avg_2 avg_3 avg_4
  132   123   23    214
  DF    DM    RF    RM
  </code></pre>
  <p>How can I convert this in R so that the output is a new data frame that looks like:</p>
  <pre><code>avg key
  132 DF
  123 DM
  23  RF
  214 RM
  </code></pre>
  <p>I have tried using <code>pivot_longer</code> from <code>tidyverse</code>, but the trouble is that I'm also trying to rename the columns to <code>avg</code> and <code>key</code>. Can anyone help?</p>