title: Pivoting a dataframe
body: <p>Any suggetions to transform a dataframe from this format to a longer format would be wonderful.
  Original data has 50 names and hundreds of YearMonths. So it should be a pivot from wide to long (?).</p>
  <pre><code>df&lt;-data.frame(name=c(&quot;Amber&quot;,&quot;Thomas&quot;,&quot;Stefan&quot;,&quot;Joe&quot;),
                        YM_202006=c(8,2,NA,7),
                 YM_202007=c(NA,4,1,7),
                 YM_202008=c(1,2,3,4))
  </code></pre>
  <p>Before transformation:</p>
  <p><a href="https://i.stack.imgur.com/tW9E8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tW9E8.png" alt="enter image description here" /></a></p>
  <p>After transformation / Desired Output (df_new):</p>
  <p><a href="https://i.stack.imgur.com/XxCn4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XxCn4.png" alt="enter image description here" /></a></p>
  <p>Desired output is faked with this code:</p>
  <pre><code>df_new&lt;- data.frame(YM=c(&quot;YM_202006&quot;,&quot;YM_202007&quot;,&quot;YM_202008&quot;),
                      Amber=c(8,NA,1),
                      Thomas=c(2,4,2),
                      Stefan=c(NA,1,3),
                      Joe=c(7,7,4))
  </code></pre>
  <p>I tried a lot of approaches without getting the desired output.</p>
  <p>Hope somebody can help, thx in advance!</p>