# NOT RUN {
# Data preparation
#::::::::::::::::::::::::::::::::::::
df <- ToothGrowth
df$dose <- as.factor(df$dose)
df$group <- factor(rep(c(1, 2), 30))
head(df)
# Stat tests
#::::::::::::::::::::::::::::::::::::
stat.test <- df %>%
t_test(len ~ dose)
stat.test
# Add the test into box plots
#::::::::::::::::::::::::::::::::::::
stat.test <- stat.test %>%
add_y_position()
# }
# NOT RUN {
if(require("ggpubr")){
ggboxplot(df, x = "dose", y = "len") +
stat_pvalue_manual(stat.test, label = "p.adj.signif", tip.length = 0.01)
}
# }
Run the code above in your browser using DataLab