r - ggplot2 显着性水平,带星号,调整后的 p 值
问题描述
我是 R 的初学者,我想知道是否可以使用 ggplot2 包在数据可视化方面获得一些帮助。
我试图用调整后的 p 值(使用 Bonferroni 校正)而不是带星号的正常 p 值来标记显着性水平。
我试过的代码是......
stat_compare_means(aes(label=..p.adj.., group=sample_type), label = "p.signif", method = "t.test", hide.ns = TRUE)
stat_compare_means(aes(group=sample_type), p.adjust.method = "bonferroni", label = "p.signif", method = "t.test", hide.ns = TRUE)
解决方案
请参阅此EnvStats
包。作者提供的示例(第 1180 页)是:
library(ggplot2)
library(EnvStats)
p <- ggplot(mtcars, aes(x = factor(cyl), y = mpg, color =
factor(cyl))) + theme(legend.position = "none")
dev.new()
p + geom_point() +
stat_n_text() + stat_mean_sd_text() +
stat_test_text() +
labs(x = "Number of Cylinders", y = "Miles per Gallon")
推荐阅读
- xaml - 尝试使用发布而不是调试运行时崩溃 - 没有错误
- python - pytest中请求超时失败时显示的所有回溯
- javascript - 如何防止 YouTube js 调用减慢页面加载速度
- javascript - 如何在 React 中通过类名访问所有 dom 元素?
- java - 用于枚举字段的 mongoDb 和 spring 数据自定义转换器
- node.js - 使用字段集查找未正确显示(node.js 和 mongodb)
- react-native - React-native:抽屉打开后黑屏(物理设备,iOS)但在模拟器上工作正常
- ruby-on-rails - Handling Single Table Inheritance with a different column
- python - 'tuple' 对象没有属性 'split'
- regex - bash:从文本字符串中解析一个数字