2013-05-12 36 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

相關問題