I´m new in R and I taught it myself so please be indulgent with me :)
I want to include the Scheffe-Test to my ggplot. I have tried with the T-Test and the Anova that worked for me. Now that I want to change it to a Scheffe-Test doesnt work for me anymore. For me the reason seems to be the missing group1 and group2 columns but I don´t know how to add them. Can anybody help? I will try to give an minimal working example:
My library:
library(tidyverse)
library(magrittr)
library(gtsummary)
library(ggpubr)
library(rstatix)
library(ggplot2)
library(DescTools)
The data:
> data_clean_bef_tbl
# A tibble: 11 × 3
time TEER Assay
<fct> <dbl> <fct>
1 -7 182 before
2 -7 194 before
3 -4 182 before
4 -4 190 before
5 -4 219 before
6 0 241 before
7 0 271 before
8 0 246 before
9 3 247 before
10 3 284 before
11 3 259 before
The ggplot:
ggplot_vor <- ggplot(data_clean_bef_tbl, aes(x = time, y = TEER)) +
geom_boxplot(aes(fill = time),
outlier.shape = NA) +
scale_fill_manual(values = c("#FFF176", "#AED581", "#4DB6AC", "#7986CB")) +
xlab("Seeding time of HT29-MTX-E12 cells compared to Caco-2 cells [days]") +
ylab("TEER [Ω*qcm]") +
theme_minimal() +
geom_point(mapping = aes(shape=time),
position = position_jitterdodge()) +
stat_summary(fun="mean", fun.min = "min", fun.max = "max",
color = "#D32F2F") +
stat_compare_means(method = "anova", label.y = 410)
The Anova- and Scheffe-Test:
anova_bef <- aov(TEER ~ time, data_clean_bef_tbl)
summary(anova_bef)
ScheffeTest(anova_bef, group = TRUE)
The T-Test that works fine for me:
stat_ttest_vor <- data_clean_bef_tbl %>%
t_test(TEER ~ time, var.equal = FALSE) %>%
adjust_pvalue(method = "bonferroni") %>%
add_significance("p.adj") %>%
add_xy_position(x = "time", dodge = 0.8)
ggplot + t-test + Anova
Boxplot_vor <- ggplot_vor +
stat_pvalue_manual(stat_ttest_vor,
label = "p.adj.signif",
step.increase = 0.02) +
scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
stat_compare_means(method = "anova", label.y = 410)
Boxplot_vor
ggplot with Anova and T-test, but I want the same with the Scheffe-Test
When I try the same with this code:
Boxplot_vor <- ggplot_vor +
stat_pvalue_manual(Scheffe_bef,
label = "pval",
step.increase = 0.02) +
scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
stat_compare_means(method = "anova", label.y = 410)
Boxplot_vor
I get the error message:
Error in asserttat_group_columns_exists(data) : data should contain group1 and group2 columns
I´ve tried to add group1 and group2 columns manually to the Scheffe-test but since it´s not a tibble, this isn´t as easy as I thought.
