【r<-方案|统计|ggplot】添加矫正p值

作者: 王诗翔 | 来源:发表于2019-05-31 19:26 被阅读29次

来源:https://github.com/kassambara/ggpubr/issues/65#issuecomment-407211245

library(tidyverse)
library(rstatix)   
library(ggpubr)

# Pairwise t-test between groups
stat.test <- ToothGrowth %>%
  group_by(dose) %>%
  t_test(len ~ supp) %>%
  adjust_pvalue() %>%
  mutate(y.position = 35)
stat.test
# A tibble: 3 x 9
   dose   .y. group1 group2  statistic      p method  p.adj y.position
                         
1   0.5   len     OJ     VC  3.1697328 0.0064 T-test 0.0128         35
2   1.0   len     OJ     VC  4.0327696 0.0010 T-test 0.0030         35
3   2.0   len     OJ     VC -0.0461361 0.9600 T-test 0.9600         35
# Create a box plot and add the p-value
p <- ggboxplot(
  ToothGrowth, x = "supp", y = "len",
  color = "supp", palette = "jco",
  facet.by = "dose", ylim = c(0, 40)
)

p + stat_pvalue_manual(stat.test, label = "p.adj")

rplot

相关文章

网友评论

    本文标题:【r<-方案|统计|ggplot】添加矫正p值

    本文链接:https://www.haomeiwen.com/subject/gkagtctx.html