2013-05-12 35 views
0

我已经有十个箱线图:意味着箱线图的符号与几个变量

boxplot(Daten$weight~interaction(Daten$Dosis,Daten$sex, drop=TRUE)) 

,并需要在他们的手段,所以我尝试:

means<-tapply(Daten$weight, Daten$Dosis, mean) 
points(means, pch=5, col="red", lwd=5) 

但结果是,我只有男性的手段点,女性发生了什么?

回答

1

在您的绘图中,拨打interaction(Dosis, sex)会产生一个因子,其中一个因子是Dosis和性别的组合。

你只需要在你的电话一样以包括tapply

# use of `with` to save typing Daten$ over and over again 
means <- with(Daten, tapply(weight, interaction(Dosis, sex), mean)) 

(注:boxplot你可以做boxplot(weight ~ interaction(Dosis, sex, drop=T), dat=Daten)保存键入Daten$全部)

+0

非常感谢! – user2373707 2013-05-12 12:02:28

相关问题