title: How to transpose a dataframe in tidyverse?
body: <p>Using  basic R, I can transpose a dataframe, say <code>mtcars</code>, which has all columns of the same class:</p>
  
  <pre><code>as.data.frame(t(mtcars))
  </code></pre>
  
  <p>Or with pipes:</p>
  
  <pre><code>library(magrittr)
  mtcars %&gt;% t %&gt;% as.data.frame
  </code></pre>
  
  <p>How to accomplish the same within tidyr or tidyverse packages?</p>
  
  <p>My attempt below gives:</p>
  
  <blockquote>
    <p>Error: Duplicate identifiers for rows</p>
  </blockquote>
  
  <pre><code>library(tidyverse)
  mtcars %&gt;% gather(var, value, everything()) %&gt;% spread(var, value)
  </code></pre>