-
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
Capital letter NS. remaining after hide.ns in ggplot with ggpubr stat_compare_means #171
Comments
Hi natjoh, I'm struggling with the same problem and have searched everywhere for a solution but unfortunately found nothing. Did you come up with a solution to this problem? Thanks in advance Sergei |
Would you please provide your session info? I can't reproduce this issue with current dev version of ggpubr. library("ggpubr")
comparisons <- list(c("ctrl", "trt1"), c("ctrl", "trt2"), c("trt1", "trt2"))
ggboxplot(PlantGrowth, x = "group", y = "weight") +
stat_compare_means(comparisons = comparisons, label = "p.signif") Hide ns: comparisons <- list(c("ctrl", "trt1"), c("ctrl", "trt2"), c("trt1", "trt2"))
ggboxplot(PlantGrowth, x = "group", y = "weight") +
stat_compare_means(comparisons = comparisons, label = "p.signif", hide.ns = TRUE) Anyway, the option An alternative solution would be to go as follow: library(rstatix) # devtools::install("kassambara/rstatix")
library(ggpubr) # devtools::install("kassambara/ggpubr")
stat.test <- PlantGrowth %>%
t_test(weight ~ group) %>%
add_xy_position()
ggboxplot(PlantGrowth, x = "group", y = "weight") +
stat_pvalue_manual(stat.test, hide.ns = TRUE) stat.test
|
I've recently come across this problem as well. The NS. is created when stat_compare_means calls geom_signif. This seems to only occur when the p-value is exactly 1 and the upper boundary of the cut values for symnum.args is 1 as well. I simply substituted a 2 for the upper value (e.g. symnum.args <- list(cutpoints = c(0, 0.05, 2), symbols = c( "*", "ns"))) and this seems to resolve the issue. |
I also came across this problem. The string |
We'll rewrite the stat_compare_means(). The following blog posts might help to add p-values onto ggplots. Consider installing the latest dev version of rstatix and ggpubr R packages. |
I want to hide.ns in a ggplot after stat_compare_means is added, it hides all but one random capital letter NS.
install.packages("tidyverse")
library(tidyverse)
library(ggpubr)
dat2<-data.frame(R_Full_simple)
R_Full_simple
#ggplot build
dat2$grp.fac <- factor(dat2$spacer_type,levels=c("1","2","0","3","4"),
labels = c("a) non-valved \n spacer", "b) valved \n spacer",
"c) direct", "d) adapter", "e) syringe") )
dat2$grp.size <- factor(dat2$ett_size,levels=c("1","2","3","4"),
labels = c("3 mm", "5 mm", "7 mm", "9 mm"))
ett <- ggplot(dat2, outlier.shape = NA, mapping = aes(x = grp.fac, y = ett_pct, fill = grp.fac))+
facet_wrap(~grp.size, scales = "free_y")+
geom_boxplot()+geom_point()+theme_classic()
ett
#compare within group
ett+stat_compare_means(comparisons = list(c("c) direct", "a) non-valved \n spacer"),
c("a) non-valved \n spacer", "b) valved \n spacer"),
c("b) valved \n spacer", "d) adapter"), c("b) valved \n spacer",
"e) syringe"),
c("d) adapter", "e) syringe"), c("c) direct", "b) valved \n spacer"),
c("c) direct", "d) adapter"), c("c) direct", "e) syringe"),
c("a) non-valved \n spacer", "e) syringe"), c("a) non-valved \n spacer",
"d) adapter")),
label = "p.signif", hide.ns = TRUE)+
stat_compare_means(method = "anova",label.y = -2)
R_Full_simple.xlsx
The text was updated successfully, but these errors were encountered: