title: tidyr - spread "Invalid column specification"
body: <p>I want to spread the DATE of the following data.frame into the columns and let the year in the rows. The structure of my data is:</p>
  
  <pre><code>&gt; str(df)
  'data.frame':   836 obs. of  3 variables:
   $ DATE: Date, format: "2014-01-03" "2014-01-04" "2014-01-06" "2014-01-07" ...
   $ VALUE    : num  1 3 1 1 2 6 1 2 1 1 ...
   $ YEAR      : chr  "2014" "2014" "2014" "2014" ...
  </code></pre>
  
  <p><code>spread(df, key=DATE, value=VALUE)</code></p>
  
  <p>But I get the error message  "Invalid column specification". Isn't spread the right function for this?</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <pre><code>&gt; str(dfTest)
  'data.frame':   836 obs. of  3 variables:
   $ DATE: Date, format: "2015-01-16" "2014-01-06" "2016-07-28" "2016-05-31" ...
   $ VALUE    : num  2 1 3 1 2 22 5 1 4 2 ...
   $ YEAR      : int  2015 2014 2016 2016 2016 2016 2017 2016 2015 2014 ...
  &gt; 
  &gt; head(dfTest)
    DATE        VALUE YEAR
  1 2015-01-16      2 2015
  2 2014-01-06      1 2014
  3 2016-07-28      3 2016
  4 2016-05-31      1 2016
  5 2016-04-28      2 2016
  6 2016-12-23     22 2016
  &gt; spread(dfTest, key=dfTest$DATE, value=dfTest$VALUE)
  Error: Invalid column specification
  </code></pre>