-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible to use stat_pvalue_manual() with dodged bar chart? #104
Comments
Please, try this: library(rstatix) # https://github.com/kassambara/rstatix
stat.test <- ToothGrowth %>%
group_by(dose) %>%
t_test(len ~ supp) %>%
adjust_pvalue() %>%
add_significance("p.adj")
library("ggpubr")
ggbarplot(ToothGrowth, x = "dose", y = "len", add = "mean_se",
color = "supp", palette = "jco",
position = position_dodge(0.8)) +
stat_pvalue_manual(stat.test, x= "dose", y.position = 30, label = "p = {p.adj}") |
kassambara
added a commit
that referenced
this issue
May 29, 2019
fixed now, thanks! Please install the latest dev version and try the R code below: df <- ToothGrowth
df$dose <- as.factor(df$dose)
# t - test
library(rstatix) # https://github.com/kassambara/rstatix
stat.test <- df %>%
group_by(supp) %>%
t_test(len ~ dose, ref.group = "0.5") %>%
adjust_pvalue() %>%
add_significance("p.adj")
stat.test
# Plot
bp <- ggbarplot(df, x = "supp", y = "len",
fill = "dose",
add = "mean_sd", add.params = list(group = "dose"),
position = position_dodge(0.8))
bp
# Add pvalue
bp + stat_pvalue_manual(
stat.test, x = "supp", y.position = 33,
label = "p.adj.signif",
position = position_dodge(0.8)
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any way to define the group names (columns 'group1' and 'group2' in the df) so that the new stat_pvalue_manual function can map the comparisons to specific bars on a dodged bar chart with grouping factors for both x and color?
The text was updated successfully, but these errors were encountered: