R ggplot中多重比较的条件p值

R ggplot中多重比较的条件p值,r,ggplot2,R,Ggplot2,我被要求提供以下表格,以便在箱线图上显示p值: 某些p范围的星号(*,***,***,***,***) 0.09>p>0.05的实际p值(仅为数字) p>0.09时无p值 我使用以下代码成功地对两组进行了比较: ggplot(ToothGrowth, aes(x=supp, y=len))+ geom_boxplot()+ stat_compare_means(mapping=aes(x=supp, y=len, label = ifelse(p > 0.05 & p

我被要求提供以下表格,以便在箱线图上显示p值:

  • 某些p范围的星号(*,***,***,***,***)
  • 0.09>p>0.05的实际p值(仅为数字)
  • p>0.09时无p值
我使用以下代码成功地对两组进行了比较:

ggplot(ToothGrowth, aes(x=supp, y=len))+
  geom_boxplot()+
  stat_compare_means(mapping=aes(x=supp, y=len, label = ifelse(p > 0.05 & p < 0.09, 
                                                               as.numeric(..p.format..), as.character(p.signif))), 
                     method="t.test", paired=FALSE,  
                     symnum.args=list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 1),
                                      symbols = c("****", "***", "**", "*", "")))

理想情况下,我还希望在p>0.09时删除括号

我非常感谢您的帮助,否则我只需要手动输入符合条件的比较

ggplot(ToothGrowth, aes(x=supp, y=len))+
  geom_boxplot()+
  stat_compare_means(mapping=aes(x=supp, y=len, label = ifelse(p > 0.05 & p < 0.09, 
                                                               as.numeric(..p.format..), as.character(p.signif))), 
                     method="t.test", paired=FALSE, comparisons = list(c(1,2)),
                     symnum.args=list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 1),
                                      symbols = c("****", "***", "**", "*", "")))