我有一个问题,当我试图使我的条形图与本教程https://www.datanovia.com/en/blog/how-to-add-p-values-onto-a-grouped-ggplot-using-the-ggpubr-r-package/
library(ggpubr)
library(rstatix)
#data
df <- ToothGrowth
df$dose <- as.factor(df$dose)
head(df, 3)
#pvalue
stat.test <- df %>%
group_by(dose) %>%
t_test(len ~ supp) %>%
adjust_pvalue(method = "bonferroni") %>%
add_significance("p.adj")
stat.test
# Create a bar plot with error bars (mean +/- sd)
bp <- ggbarplot(
df, x = "dose", y = "len", add = "mean_sd",
color= "supp", palette = c("#00AFBB", "#E7B800"),
position = position_dodge(0.8)
) + geom_point()
# Add p-values onto the bar plots
stat.test <- stat.test %>%
add_xy_position(fun = "mean_sd", x = "dose", dodge = 0.8)
bp + stat_pvalue_manual(
stat.test, label = "p.adj.signif", tip.length = 0.01
)
# Move down the brackets using `bracket.nudge.y`
bp + stat_pvalue_manual(
stat.test, label = "p.adj.signif", tip.length = 0,
bracket.nudge.y = -2
)
我试图添加数据点,但点无法与列对齐。
x1c 0d1x非常感谢您的帮助!
1条答案
按热度按时间yzuktlbb1#
我终于找到了方法:
非常感谢