#| label = "setup", #| include = FALSE source("../setup.R")
#| label = "suggested_pkgs", #| include = FALSE pkgs <- "PMCMRplus" successfully_loaded <- purrr::map_lgl(pkgs, requireNamespace, quietly = TRUE) can_evaluate <- all(successfully_loaded) if (can_evaluate) { purrr::walk(pkgs, library, character.only = TRUE) } else { knitr::opts_chunk$set(eval = FALSE) }
You can cite this package/vignette as:
#| label = "citation", #| echo = FALSE, #| comment = "" citation("ggstatsplot")
Pairwise comparisons with {ggstatsplot}
.
Following table contains a brief summary of the currently supported pairwise comparison tests-
Type | Equal variance? | Test | p-value adjustment? | Function used
----------- | --- | ------------------------- | --- | -----
Parametric | No | Games-Howell test | ✅ | PMCMRplus::gamesHowellTest
Parametric | Yes | Student's t-test | ✅ | stats::pairwise.t.test
Non-parametric | No | Dunn test | ✅ | PMCMRplus::kwAllPairsDunnTest
Robust | No | Yuen's trimmed means test | ✅ | WRS2::lincon
Bayesian | NA
| Student's t-test | NA
| BayesFactor::ttestBF
Type | Test | p-value adjustment? | Function used
----------- | ---------------------------- | --- | -----
Parametric | Student's t-test | ✅ | stats::pairwise.t.test
Non-parametric | Durbin-Conover test | ✅ | PMCMRplus::durbinAllPairsTest
Robust | Yuen's trimmed means test | ✅ | WRS2::rmmcp
Bayesian | Student's t-test | NA
| BayesFactor::ttestBF
See data frame outputs here.
pairwise_comparisons()
with ggsignif
#| label = "ggsignif", #| fig.height = 5 library(ggplot2) library(ggsignif) ## converting to factor mtcars$cyl <- as.factor(mtcars$cyl) ## creating a basic plot p <- ggplot(mtcars, aes(cyl, wt)) + geom_boxplot() ## using `pairwise_comparisons()` package to create a data frame with results df <- pairwise_comparisons(mtcars, cyl, wt) %>% dplyr::mutate(groups = purrr::pmap(.l = list(group1, group2), .f = c)) %>% dplyr::arrange(group1) df ## using `geom_signif` to display results ## (note that you can choose not to display all comparisons) p + ggsignif::geom_signif( comparisons = list(df$groups[[1]]), annotations = as.character(df$expression)[[1]], test = NULL, na.rm = TRUE, parse = TRUE )
#| label = "ggsignif2", #| fig.height = 7 library(ggplot2) library(ggsignif) ## creating a basic plot p <- ggplot(WRS2::WineTasting, aes(Wine, Taste)) + geom_boxplot() ## using `pairwise_comparisons()` package to create a data frame with results df <- pairwise_comparisons( WRS2::WineTasting, Wine, Taste, subject.id = Taster, type = "bayes", paired = TRUE ) %>% dplyr::mutate(groups = purrr::pmap(.l = list(group1, group2), .f = c)) %>% dplyr::arrange(group1) df ## using `geom_signif` to display results p + ggsignif::geom_signif( comparisons = df$groups, map_signif_level = TRUE, tip_length = 0.01, y_position = c(6.5, 6.65, 6.8), annotations = as.character(df$expression), test = NULL, na.rm = TRUE, parse = TRUE )
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.