get_y_position | R Documentation |
Compute p-value x and y positions for plotting significance levels. Many examples are provided at :
get_y_position( data, formula, fun = "max", ref.group = NULL, comparisons = NULL, step.increase = 0.12, y.trans = NULL, stack = FALSE, scales = c("fixed", "free", "free_y") ) add_y_position( test, fun = "max", step.increase = 0.12, data = NULL, formula = NULL, ref.group = NULL, comparisons = NULL, y.trans = NULL, stack = FALSE, scales = c("fixed", "free", "free_y") ) add_x_position(test, x = NULL, group = NULL, dodge = 0.8) add_xy_position( test, x = NULL, group = NULL, dodge = 0.8, stack = FALSE, fun = "max", step.increase = 0.12, scales = c("fixed", "free", "free_y"), ... )
data |
a data.frame containing the variables in the formula. |
formula |
a formula of the form |
fun |
summary statistics functions used to compute automatically suitable
y positions of p-value labels and brackets. Possible values include:
For example, if
When the main plot is a boxplot, you need the option In some situations the main plot is a line plot or a barplot showing the
|
ref.group |
a character string specifying the reference group. If specified, for a given grouping variable, each of the group levels will be compared to the reference group (i.e. control group). |
comparisons |
A list of length-2 vectors specifying the groups of
interest to be compared. For example to compare groups "A" vs "B" and "B" vs
"C", the argument is as follow: |
step.increase |
numeric vector with the increase in fraction of total height for every additional comparison to minimize overlap. |
y.trans |
a function for transforming y axis scale. Value can be
|
stack |
logical. If TRUE, computes y position for a stacked plot. Useful when dealing with stacked bar plots. |
scales |
Should scales be fixed ( |
test |
an object of class |
x |
variable on x axis. |
group |
group variable (legend variable). |
dodge |
dodge width for grouped ggplot/test. Default is 0.8. Used only
when |
... |
other arguments to be passed to the function
|
get_y_position()
: compute the p-value y positions
add_y_position()
: add p-value y positions to an object of class rstatix_test
add_x_position()
: compute and add p-value x positions.
add_xy_position()
: compute and add both x and y positions.
# Data preparation #:::::::::::::::::::::::::::::::::::: df <- ToothGrowth df$dose <- as.factor(df$dose) df$group <- factor(rep(c(1, 2), 30)) head(df) # Stat tests #:::::::::::::::::::::::::::::::::::: stat.test <- df %>% t_test(len ~ dose) stat.test # Add the test into box plots #:::::::::::::::::::::::::::::::::::: stat.test <- stat.test %>% add_y_position() if(require("ggpubr")){ ggboxplot(df, x = "dose", y = "len") + stat_pvalue_manual(stat.test, label = "p.adj.signif", tip.length = 0.01) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.