[R] contrast package tutorial

Peng Yu pengyu.ut at gmail.com
Wed Feb 3 06:09:22 CET 2010


I read the vignette of contrast package. I don't think that I
understand how to use it.

I made the following simpler example (contrast between '3' and '4').
Could somebody let me know what is the correct way to compute the
contrast in the following example?

 library(contrast)

 a=3
 n=4
 A = as.vector(sapply(1:a,function(x){rep(x,n)}))
 Y = A + rnorm(a*n)

 aframe = data.frame(Y=Y, A=as.factor(A))
 aframe
 afit=aov(Y ~ A - 1, aframe)

 contrast(afit, list=(A='3'), list=(A='4'))



More information about the R-help mailing list