## The main reason for wanting such a coding is to use it in
## a linear model.  Therefore, declare the variable to be a factor
## and use it directly.


tmp <- sample(1:5, 40, replace=TRUE)
tmpf <- factor(tmp)
tmp.y <- rnorm(40)

tmp.aov <- aov(tmp.y ~ tmpf)
summary(tmp.aov)

contrasts(tmpf)

update(tmp.aov, x=TRUE)$x[1:6,]

## If you really want to see the redundant column 1 of
## of the contrasts, that can be done with the statement

contrasts(tmpf)
contrasts(tmpf, how.many=5) <- contr.treatment(5, contrasts=FALSE)
contrasts(tmpf)

tmp2.aov <- aov(tmp.y ~ tmpf)
summary(tmp2.aov)
update(tmp2.aov, x=TRUE)$x[1:6,]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to