[R] TukeyHSD troubles

RICHARD M. HEIBERGER rmh at temple.edu
Fri Feb 26 08:08:34 CET 2010


> treat_code is a dummy
> variable, but that shouldn't matter.  Any suggestions?

It does matter to TukeyHSD.  If treat_code is a numeric variable with discrete
values 0 and 1, then it does not have class "factor".  It is true that
aov will give the same
ANOVA table for a two-level factor as for a two-value numeric.  It will give
different ANOVA tables if there are more than two values.  TukeyHSD will refuse
to do anything for a numeric variable.  It insists on factors.

You must use the statement
  mydata$treat_code <- factor(mydata$treat_code)
before creating the aov object that you give to TukeyHSD.

Rich



More information about the R-help mailing list