title: Using spread to create two value columns with tidyr
body: <p>I have a data frame that looks just like this (see link).  I'd like to take the output that is produced below and go one step further by spreading the tone variable across both the n and the average variables. It seems like this  topic might bear on this, but I can't get it to work:
  <a href="https://stackoverflow.com/questions/24929954/is-it-possible-to-use-spread-on-multiple-columns-in-tidyr-similar-to-dcast">Is it possible to use spread on multiple columns in tidyr similar to dcast?</a></p>
  
  <p>I'd like the final table to have the source variable in one column, then then the tone-n and tone-avg variables to be in columns.  So I'd like the column headers to be "source" - "For - n" - "Against - n" "For -Avg" - "Against - Avg".  This is for publication, not for further calculation, so it's about presenting data. It seems more intuitive to me to present data in this way.  Thank you.</p>
  
  <pre><code>#variable1
  Politician.For&lt;-sample(seq(0,4,1),50, replace=TRUE)
  #variable2
  Politician.Against&lt;-sample(seq(0,4,1),50, replace=TRUE)
  #Variable3
  Activist.For&lt;-sample(seq(0,4,1),50,replace=TRUE)
  #variable4
  Activist.Against&lt;-sample(seq(0,4,1),50,replace=TRUE)
  #dataframe
  df&lt;-data.frame(Politician.For, Politician.Against, Activist.For,Activist.Against)
  
  #tidyr
  df %&gt;%
   #Gather all columns 
   gather(df) %&gt;%
   #separate by the period character 
   #(default separation character is non-alpha numeric characterr) 
   separate(col=df, into=c('source', 'tone')) %&gt;%
   #group by both source and tone  
   group_by(source,tone) %&gt;%
   #summarise to create counts and average
   summarise(n=sum(value), avg=mean(value)) %&gt;%
   #try to spread
   spread(tone, c('n', 'value'))
  </code></pre>