r - ggplot中多重比较的条件p值
问题描述
我被要求使用以下表格在箱线图上显示 p 值:
- 某些 p 范围的星号(*、**、***、***)
- 0.09 > p > 0.05 的实际 p 值(只是数字)
- p > 0.09 没有 p 值
我设法使用此代码使其仅用于比较两组:
ggplot(ToothGrowth, aes(x=supp, y=len))+
geom_boxplot()+
stat_compare_means(mapping=aes(x=supp, y=len, label = ifelse(p > 0.05 & p < 0.09,
as.numeric(..p.format..), as.character(p.signif))),
method="t.test", paired=FALSE,
symnum.args=list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 1),
symbols = c("****", "***", "**", "*", "")))
现在我有一些带有多重比较的图。我在那里使用comparisons = list(c(1,2), c(1,3), c(2,3))
不幸的是,一旦我添加了比较参数,上述解决方案就不再有效。
ggplot(ToothGrowth, aes(x=supp, y=len))+
geom_boxplot()+
stat_compare_means(mapping=aes(x=supp, y=len, label = ifelse(p > 0.05 & p < 0.09,
as.numeric(..p.format..), as.character(p.signif))),
method="t.test", paired=FALSE, comparisons = list(c(1,2)),
symnum.args=list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 1),
symbols = c("****", "***", "**", "*", "")))
理想情况下,我还想在 p > 0.09 时删除括号。
我感谢任何帮助,否则我将需要手动放置符合标准的比较。
解决方案
推荐阅读
- hybris - Hybris 促销容器
- python - 字典值比较和重新分配
- python - 基于先前参数的 Cmd2 argparse 选项卡完成
- elixir - Ecto.Multi - 插入两条相关记录
- git - 无法获得 github 的命令行授权
- r - 在R中选择空单元格
- node.js - 如何获得 Sequelize 结果 WHERE MAX timestamps_of_multiple_nested_objects 大于某个日期?
- r - 如何找到 OPENDAP URL(NetCDF 文件)的正确 MIME 内容类型?
- python - fastapi 提取所有路径参数键和值
- arrays - 如何将列表框中的项目写入数组 VBA