title: Comparing gather (tidyr) to melt (reshape2)
body: <p>I love the <strong>reshape2</strong> package because it made life so doggone easy.  Typically Hadley has made improvements in his previous packages that enable streamlined, faster running code.  I figured I'd give <strong>tidyr</strong> a whirl and from what I read I thought <code>gather</code> was very similar to <code>melt</code> from <strong>reshape2</strong>.  But after reading the documentation I can't get <code>gather</code> to do the same task that <code>melt</code> does.</p>
  
  <p><strong>Data View</strong></p>
  
  <p>Here's a view of the data (actual data in <code>dput</code> form at end of post):</p>
  
  <pre><code>  teacher yr1.baseline     pd yr1.lesson1 yr1.lesson2 yr2.lesson1 yr2.lesson2 yr2.lesson3
  1       3      1/13/09 2/5/09      3/6/09     4/27/09     10/7/09    11/18/09      3/4/10
  2       7      1/15/09 2/5/09      3/3/09      5/5/09    10/16/09    11/18/09      3/4/10
  3       8      1/27/09 2/5/09      3/3/09     4/27/09     10/7/09    11/18/09      3/5/10
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <p>Here's the code in <code>melt</code> fashion, my attempt at <code>gather</code>.  How can I make <code>gather</code> do the same thing as <code>melt</code>?      </p>
  
  <pre><code>library(reshape2); library(dplyr); library(tidyr)
  
  dat %&gt;% 
     melt(id=c("teacher", "pd"), value.name="date") 
  
  dat %&gt;% 
     gather(key=c(teacher, pd), value=date, -c(teacher, pd)) 
  </code></pre>
  
  <p><strong>Desired Output</strong></p>
  
  <pre><code>   teacher     pd     variable     date
  1        3 2/5/09 yr1.baseline  1/13/09
  2        7 2/5/09 yr1.baseline  1/15/09
  3        8 2/5/09 yr1.baseline  1/27/09
  4        3 2/5/09  yr1.lesson1   3/6/09
  5        7 2/5/09  yr1.lesson1   3/3/09
  6        8 2/5/09  yr1.lesson1   3/3/09
  7        3 2/5/09  yr1.lesson2  4/27/09
  8        7 2/5/09  yr1.lesson2   5/5/09
  9        8 2/5/09  yr1.lesson2  4/27/09
  10       3 2/5/09  yr2.lesson1  10/7/09
  11       7 2/5/09  yr2.lesson1 10/16/09
  12       8 2/5/09  yr2.lesson1  10/7/09
  13       3 2/5/09  yr2.lesson2 11/18/09
  14       7 2/5/09  yr2.lesson2 11/18/09
  15       8 2/5/09  yr2.lesson2 11/18/09
  16       3 2/5/09  yr2.lesson3   3/4/10
  17       7 2/5/09  yr2.lesson3   3/4/10
  18       8 2/5/09  yr2.lesson3   3/5/10
  </code></pre>
  
  <p><strong>Data</strong></p>
  
  <pre><code>dat &lt;- structure(list(teacher = structure(1:3, .Label = c("3", "7", 
      "8"), class = "factor"), yr1.baseline = structure(1:3, .Label = c("1/13/09", 
      "1/15/09", "1/27/09"), class = "factor"), pd = structure(c(1L, 
      1L, 1L), .Label = "2/5/09", class = "factor"), yr1.lesson1 = structure(c(2L, 
      1L, 1L), .Label = c("3/3/09", "3/6/09"), class = "factor"), yr1.lesson2 = structure(c(1L, 
      2L, 1L), .Label = c("4/27/09", "5/5/09"), class = "factor"), 
          yr2.lesson1 = structure(c(2L, 1L, 2L), .Label = c("10/16/09", 
          "10/7/09"), class = "factor"), yr2.lesson2 = structure(c(1L, 
          1L, 1L), .Label = "11/18/09", class = "factor"), yr2.lesson3 = structure(c(1L, 
          1L, 2L), .Label = c("3/4/10", "3/5/10"), class = "factor")), .Names = c("teacher", 
      "yr1.baseline", "pd", "yr1.lesson1", "yr1.lesson2", "yr2.lesson1", 
      "yr2.lesson2", "yr2.lesson3"), row.names = c(NA, -3L), class = "data.frame")
  </code></pre>