title: Contrasts for lm using contrast package
body: <p>I'm using <code>contrast</code> package to construct contrasts for <code>lm</code> in <code>R</code>. With the following code I'm making contrast between Trt1 and Trt3.</p>
  
  <pre><code>Y &lt;- c(10, 12, 14, 16, 9, 8)
  Trt &lt;- gl(n=3, k=2, length=3*2)
  Data1 &lt;- data.frame(Y, Trt)
  
  Data1.lm &lt;- lm(Y~Trt, data = Data1)
  
  library(contrast)
  Contrs1 &lt;- contrast(Data1.lm, a=list(Trt="1"), b=list(Trt="3"), type = "average")
  print(Contrs1, X=TRUE)
  </code></pre>
  
  <p>I'd like to make a contrast between the average of  (Trt1 and Trt2) and Trt3. I used this code</p>
  
  <pre><code>Contrs2 &lt;- contrast(Data1.lm, a=list(Trt="1", Trt="2"), b=list(Trt="3"), type = "average")
  print(Contrs2, X=TRUE)
  
  lm model parameter contrast
  
    Contrast     S.E.    Lower    Upper    t df Pr(&gt;|t|)
  1      6.5 1.224745 2.602315 10.39768 5.31  3   0.0131
  
  Contrast coefficients:
    (Intercept) Trt2 Trt3
  1           0    1   -1
  </code></pre>
  
  <p>I can see that this is not the desired contrast. I wonder how to get the correct contrast with the <code>contrast</code> package in <code>R</code>. Any help in this regard will be highly appreciated. Thanks</p>
  
  <p>P.S. I know to do use the contrast matrix for <code>aov</code> function in <code>R</code> but for this particular problem I want to use <code>contrast</code> package.</p>