title: Use dplyr/tidyr to turn rows into columns in R data frame
body: <p>I have a data frame like this:</p>
  
  <pre><code>year &lt;-c(floor(runif(100,min=2015, max=2017)))
  month &lt;- c(floor(runif(100, min=1, max=13)))
  inch &lt;- c(floor(runif(100, min=0, max=10)))
  mm &lt;- c(floor(runif(100, min=0, max=100)))
  df = data.frame(year, month, inch, mm);
  
  year month inch mm
  2016    11    0 10
  2015     9    3 34
  2016     6    3 33
  2015     8    0 77
  </code></pre>
  
  <p>I only care about the columns <code>year</code>, <code>month</code>, and <code>mm</code>. </p>
  
  <p>I need to re-arrange the data frame so that the first column is the name of the month and the rest of the columns is the value of <code>mm</code>.</p>
  
  <pre><code>Months  2015  2016
  Jan     #    #
  Feb
  Mar
  Apr
  May
  Jun
  Jul
  Aug
  Sep
  Oct
  Nov
  Dec
  </code></pre>
  
  <p>So two things needs to happen. 
  (1) The month needs to become a string of the first three letters of the month. 
  (2) I need to group by year, and then put the <code>mm</code> values in a column under that year. </p>
  
  <p>So far I have this code, but I can't figure it out:</p>
  
  <pre><code>df %&gt;% 
    select(-inch) %&gt;% 
    group_by(month) %&gt;% 
    summarize(mm = mm) %&gt;% 
    ungroup()
  </code></pre>