Greetings, I want to use the following with my own data but have a couple of questions about the resulting graphs.
dat <- iris
# Edit from here
x <- which(names(dat) == "Species") # name of grouping variable
y <- which(names(dat) == "Sepal.Length" # names of variables to test
| names(dat) == "Sepal.Width"
| names(dat) == "Petal.Length"
| names(dat) == "Petal.Width")
method1 <- "anova" # one of "anova" or "kruskal.test"
method2 <- "t.test" # one of "wilcox.test" or "t.test"
my_comparisons <- list(c("setosa", "versicolor"), c("setosa", "virginica"), c("versicolor", "virginica")) # comparisons for post-hoc tests
# Edit until here
# Edit at your own risk
for (i in y) {
for (j in x) {
p <- ggboxplot(dat,
x = colnames(dat[j]), y = colnames(dat[i]),
color = colnames(dat[j]),
legend = "none",
palette = "npg",
add = "jitter"
)
print(
p + stat_compare_means(aes(label = paste0(..method.., ", p-value = ", ..p.format.., " (", ifelse(..p.adj.. > 0.05, "not significant", ..p.signif..), ")")),
method = method1, label.y = max(dat[, i], na.rm = TRUE)
)
+ stat_compare_means(comparisons = my_comparisons, method = method2, label = "p.format") # remove if p-value of ANOVA or Kruskal-Wallis test >= 0.05
)
}
}
Questions
- In the first graph, is the top value shown "1.9e-07" a p-value?
- If so, why isn't it written out as such?
- If son, is it considered significant?
- If so, why aren't asterisks shown?
- The second and third numbers are p-values
- Are they significant?
- If so, why aren't asterisks shown?
- What level of significance do the 4 asterisks shown represent?
- Could a graph have comparisons with p-values at different levels of significance (e.g., 0.05, 0.01, 0.001 etc.)?
Any help interpreting these graphs would be very helpful. Thank you.
Jason
#rstatsnewbie
p.s. the original code was found here:
Communicating ANOVA results a better way