【问题标题】:ggplot2 significance level with asterisk with adjusted p valuesggplot2 显着性水平,带星号,调整后的 p 值
【发布时间】:2020-06-19 09:35:46
【问题描述】:

我是 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)

【问题讨论】:

  • 如果您包含一个简单的reproducible example,其中包含可用于测试和验证可能解决方案的示例输入和所需输出,则更容易为您提供帮助。

标签: r ggplot2 statistics p-value


【解决方案1】:

请参阅EnvStats 包。 example provided by the authors(第 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")

【讨论】:

    猜你喜欢
    • 2015-10-01
    • 2013-06-09
    • 2021-06-13
    • 2019-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多