Thanks, I'll look at that.

In the meantime, the code below is what I came up with myself. It does
what I want

# SelectCases(dat,crit) == subset(dat, crit, drop=FALSE)

SENSICK.AvScores<- function( dat=SENSICK.items.tr )
{
        n<-nlevels(dat$Symptom)
        data.frame(
                Patient=c( rep(1,n), rep(0, 3*n)),
                WasSick=c( rep(1,2*n), rep(NA,2*n)),
                StrictSick=c( rep(NA,2*n), rep(-1,n), rep(1,n)),
                Symptom=rep(levels(dat$Symptom),4),
                AvScore=c(
                        with( SelectCases(dat, 'Patient==1 & WasSick==1'), 
tapply(Score,
Symptom , mean) ),
                        with( SelectCases(dat, 'Patient==0 & WasSick==1'), 
tapply(Score,
Symptom , mean) ),
                        with( SelectCases(dat, 'Patient==0 & StrictSick==-1'),
tapply(Score, Symptom , mean) ),
                        with( SelectCases(dat, 'Patient==0 & StrictSick==1'), 
tapply(Score,
Symptom , mean) )
                )
        )
}

AvScores<-SENSICK.AvScores

with( AvScores, (barchart( AvScore[Patient==1] - AvScore[Patient==0 &
WasSick==1]) ~ Symptom, scales=list( rot=c(45,0)) )

------ Dieter wrote:
Maybe it's a bit more than you want, but possibly you are happy with it: see the
example under TukeyHSD.

summary(fm1 <- aov(breaks ~ wool + tension, data = warpbreaks))
TukeyHSD(fm1, "tension", ordered = TRUE)
plot(TukeyHSD(fm1, "tension"))


Dieter

______________________________________________
R-help@stat.math.ethz.ch 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