ggstatsplot (version 0.1.2)

ggsignif_adder: Adding geom_signif to ggplot

Description

Adding geom_signif to ggplot

Usage

ggsignif_adder(plot, df_pairwise, data, x, y,
  pairwise.annotation = "p.value", pairwise.display = "significant")

Arguments

plot

A ggplot object on which geom_signif needed to be added.

df_pairwise

A dataframe containing results from pairwise comparisons (produced by pairwiseComparisons::pairwise_comparisons() function).

data

A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.

x

The grouping variable from the dataframe data.

y

The response (a.k.a. outcome or dependent) variable from the dataframe data.

pairwise.annotation

Character that decides the annotations to use for pairwise comparisons. Either "p.value" (default) or "asterisk".

pairwise.display

Decides which pairwise comparisons to display. Available options are "significant" (abbreviation accepted: "s") or "non-significant" (abbreviation accepted: "ns") or "everything"/"all". The default is "significant". You can use this argument to make sure that your plot is not uber-cluttered when you have multiple groups being compared and scores of pairwise comparisons being displayed.

Examples

Run this code
# NOT RUN {
set.seed(123)
library(ggplot2)

# plot
p <- ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot()

# dataframe with pairwise comparison test results
df_pair <- pairwiseComparisons::pairwise_comparisons(
  data = iris,
  x = Species,
  y = Sepal.Length
)

# adding a geom for pairwise comparisons
ggstatsplot:::ggsignif_adder(
  plot = p,
  data = iris,
  x = Species,
  y = Sepal.Length,
  df_pairwise = df_pair
)
# }

Run the code above in your browser using DataCamp Workspace