[R] How Rcmdr or na.exclude blocks TukeyHSD
Muenchen, Robert A (Bob)
muenchen at utk.edu
Tue Oct 23 22:13:38 CEST 2012
Dear R-Helpers,
I was calling the TukeyHSD function and not getting confidence intervals or p-values. It turns out this was caused by missing data and the fact that I had previously turned on R Commander (Rcmdr). John Fox knew that Rcmdr sets na.action to na.exclude, which causes the problem. If you have this problem, you can either exit Rcmdr before calling TukeyHSD or you can set na.action to na.omit. The code below demonstrates the situation.
Cheers,
Bob
data(warpbreaks)
head(warpbreaks)
# Introduce a missing value:
warpbreaks$breaks[1] <- NA
head(warpbreaks)
# Do a model:
fm1 <- aov(breaks ~ tension, data = warpbreaks)
TukeyHSD(fm1, "tension", ordered = TRUE)
# Setting na.exclude or starting Rcmdr will kill the confidence intervals:
options(na.action = na.exclude)
fm1 <- aov(breaks ~ tension, data = warpbreaks)
TukeyHSD(fm1, "tension", ordered = TRUE)
# Setting na.omit or exiting Rcmdr will get it working again:
options(na.action=na.omit)
fm1 <- aov(breaks ~ tension, data = warpbreaks)
TukeyHSD(fm1, "tension", ordered = TRUE)
=========================================================
Bob Muenchen (pronounced Min'-chen), Manager
Research Computing Support
Voice: (865) 974-5230
Email: muenchen at utk.edu
Web: http://oit.utk.edu/research,
News: http://itc2.utk.edu/newsletter_monthly/
========================================================
More information about the R-help
mailing list