首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >「R」ggplot2 添加矫正p值

「R」ggplot2 添加矫正p值

作者头像
王诗翔呀
发布2020-07-03 17:52:38
发布2020-07-03 17:52:38
1.8K0
举报
文章被收录于专栏:优雅R优雅R

ggpubr 实现了 ggplot2 绘图添加 p 值的良好支持,但读者需要注意它是没有经常矫正的。矫正 p 值需要额外的处理。

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

代码语言:javascript
复制
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")

参考资料

[1]

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

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-05-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 优雅R 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 参考资料
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档