如何解决R 在分组条形图中显示水平显着性
我正在寻找一种使用 ggplot 和 ggpubr 计算和绘制 R 中分组条形图中某些级别的显着性的方法。有一些可用的信息,但它们似乎都不适用于该特殊问题。基础数据似乎是一个聚合表,如下所示:
survey1 <- as.data.frame(replicate(3,sample(0:1,4,rep=TRUE)))
survey1$V1 <- runif(4)
survey1$V1 <- survey1$V1/sum(survey1$V1)
survey1$V2 <- "survey1"
survey1$V3 <- 1:4
survey1$variable <- "F2500"
colnames(survey1)[1] <- "percent"
colnames(survey1)[2] <- "survey"
colnames(survey1)[3] <- "level"
survey2 <- as.data.frame(replicate(3,rep=TRUE)))
survey2$V1 <- runif(4)
survey2$V1 <- survey2$V1/sum(survey2$V1)
survey2$V2 <- "survey2"
survey2$V3 <- 1:4
survey2$variable <- "F2500"
colnames(survey2)[1] <- "percent"
colnames(survey2)[2] <- "survey"
colnames(survey2)[3] <- "level"
sum.tab <- rbind(survey1,survey2)
我绘制这个变量的方法如下:
library(ggpubr)
library(ggplot2)
ggbarplot(sum.tab,x = "level",y = "percent",fill = "survey",color = NA,position = position_dodge2(preserve = "single",padding = 0)) +
stat_compare_means(aes(group = survey),label = "p.format")
然而,它显示了一个结果,但似乎不太正确。 我正在寻找一种方法来在函数中运行具有类似绘图代码的几十个变量......但我还没有做到。
抱歉,如果我之前看过有关该问题的帖子(也许我对它们的理解不够)。
感谢您的帮助!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。