title: How to use the spread function properly in tidyr
body: <p>How do I change the following table from:</p>
  
  <pre><code>Type    Name    Answer     n
  TypeA   Apple   Yes        5
  TypeA   Apple   No        10
  TypeA   Apple   DK         8
  TypeA   Apple   NA        20
  TypeA   Orange  Yes        6
  TypeA   Orange  No        11
  TypeA   Orange  DK         8
  TypeA   Orange  NA        23
  </code></pre>
  
  <p>Change to:</p>
  
  <pre><code>Type    Name    Yes   No   DK   NA  
  TypeA   Apple   5     10   8    20
  TypeA   Orange  6     11   8    23
  </code></pre>
  
  <p>I used the following codes to get the first table.</p>
  
  <pre><code>df_1 &lt;- 
    df %&gt;% 
    group_by(Type, Name, Answer) %&gt;% 
    tally()  
  </code></pre>
  
  <p>Then I tried to use the spread command to get to the 2nd table, but I got the following error message:</p>
  
  <blockquote>
    <p>"Error: All columns must be named"</p>
  </blockquote>
  
  <pre><code>df_2 &lt;- spread(df_1, Answer)
  </code></pre>