I need to add p values to my grouped plot in my boxplot

25 Views Asked by At

I am running the following code:

 ggboxplot(Test, x = "pH", y = "Value", color = "Treatment", palette = "jco", add = "jitter") + geom_signif(comparisons = list(c("Control", "PEF")), map_signif_level = TRUE, textsize = 5, vjust = -1, show.legend = FALSE)

And I am getting the error "Warning message:

Computation failed in `stat_signif()`
Caused by error in `if (scales$x$map(comp[1]) == data$group[1] | manual) 

! missing value where TRUE/FALSE needed "

I changed my character columns to factor, I used the following code and then again tried to run the code for boxplot mentioned above

 Test$pH <- factor(Test$pH, levels = c("pH1", "pH2", "pH3", "pH4", "pH5", "pH6", "pH7", "pH8", "pH9", "pH10", "pH11", "pH12"))

t_test_results <- Test %>%

  • group_by(pH) %>%
    
  • summarize(p_value = t.test(Value ~ Treatment)$p.value)
    

t_test_results$pH <- factor(t_test_results$pH, levels = levels(Test$pH))" but it still gives me the same error.

0

There are 0 best solutions below