将Tukey的重要性字母添加到箱线图中 [英] Adding Tukey's significance letters to boxplot

查看:67
本文介绍了将Tukey的重要性字母添加到箱线图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用yaxis上的计数ggplot(MedMean)和xaxis上的各种独立样本(Site_Name)创建箱形图.

I'm trying to create a boxplot with ggplot of a count (MedMean) on yaxis and various independent samples (Site_Name) on xaxis.

ggplot(medianlist,aes(x=reorder(Site_Name,MedMean,FUN=median),y=MedMean))+
geom_boxplot()

我想在框中添加Tukey的重要字母.

I want to add Tukey's significance letters to the boxes.

谢谢

推荐答案

您可以使用 agricolae :: HSD.test

library(dplyr)
library(agricolae)
library(ggplot2)
iris.summarized = iris %>% group_by(Species) %>% summarize(Max.Petal.Length=max(Petal.Length))
hsd=HSD.test(aov(Petal.Length~Species,data=iris), "Species", group=T)
ggplot(iris,aes(x=reorder(Species,Petal.Length,FUN = median),y=Petal.Length))+geom_boxplot()+geom_text(data=iris.summarized,aes(x=Species,y=0.2+Max.Petal.Length,label=hsd$groups$groups),vjust=0)

这篇关于将Tukey的重要性字母添加到箱线图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆