# A factor with 5 levels
fact <- gl(5,10,labels=LETTERS[1:5])
# A matrix of contrasts with all possible pairwise comparisons
mat.cont(fact)
# A matrix with only comparisons to level "A"
mat.cont(fact,ref="A")
# A matrix with all pairwise comparisons between "A", "B" and "E"
mat.cont(fact,restrict=c("A","B","E"))
# The same with levels "C" and "D" excluded
mat.cont(fact,restrict=c("A","B","E"),exclude=TRUE)
Run the code above in your browser using DataLab