title: How to properly set contrasts in R
body: <p>I have been asked to see if there is a linear trend in 3 groups of data (5 points each) by using ANOVA and linear contrasts. The 3 groups represent data collected in <code>2010</code>, <code>2011</code> and <code>2012</code>. I want to use R for this procedure and I have tried both of the following:  </p>
  
  <pre><code>contrasts(data$groups, how.many=1) &lt;- contr.poly(3)
  contrasts(data$groups)  &lt;- contr.poly(3)
  </code></pre>
  
  <p>Both ways seem to work fine but give slightly different answers in terms of their p-values. I have no idea which is correct and it is really tricky to find help for this on the web. I would like help figuring out what is the reasoning behind the different answers. I'm not sure if it has something to do with partitioning sums of squares or whatnot. </p>