我是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
程序包。作者提供的示例是:
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")