View source: R/ggadjust_pvalue.R
ggadjust_pvalue | R Documentation |
Adjust p-values produced by geom_pwc()
on a ggplot.
This is mainly useful when using facet, where p-values are generally
computed and adjusted by panel without taking into account the other panels.
In this case, one might want to adjust after the p-values of all panels together.
ggadjust_pvalue( p, layer = NULL, p.adjust.method = "holm", label = "p.adj", hide.ns = NULL, symnum.args = list(), output = c("plot", "stat_test") )
p |
a ggplot |
layer |
An integer indicating the statistical layer rank in the ggplot (in the order added to the plot). |
p.adjust.method |
method for adjusting p values (see
|
label |
character string specifying label. Can be:
. |
hide.ns |
can be logical value ( |
symnum.args |
a list of arguments to pass to the function
In other words, we use the following convention for symbols indicating statistical significance:
|
output |
character. Possible values are one of |
# Data preparation #::::::::::::::::::::::::::::::::::::::: df <- ToothGrowth df$dose <- as.factor(df$dose) # Add a random grouping variable df$group <- factor(rep(c("grp1", "grp2"), 30)) head(df, 3) # Boxplot: Two groups by panel #::::::::::::::::::::::::::::::::::::::: # Create a box plot bxp <- ggboxplot( df, x = "supp", y = "len", fill = "#00AFBB", facet.by = "dose" ) # Make facet and add p-values bxp <- bxp + geom_pwc(method = "t_test") bxp # Adjust all p-values together after ggadjust_pvalue( bxp, p.adjust.method = "bonferroni", label = "{p.adj.format}{p.adj.signif}", hide.ns = TRUE ) # Boxplot: Three groups by panel #::::::::::::::::::::::::::::::::::::::: # Create a box plot bxp <- ggboxplot( df, x = "dose", y = "len", fill = "#00AFBB", facet.by = "supp" ) # Make facet and add p-values bxp <- bxp + geom_pwc(method = "t_test") bxp # Adjust all p-values together after ggadjust_pvalue( bxp, p.adjust.method = "bonferroni", label = "{p.adj.format}{p.adj.signif}" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.