const-ae/ggsignif

How do I annotate the difference between 2 groups without using the test argument?

satvirsaggi opened this issue · 1 comments

I want to add manual annotations between two groups without performing one of the tests (wilcox, t test, etc.) . However, it seems like I am running into an error.

Warning: Computation failed in stat_signif():
missing value where TRUE/FALSE needed

Is there a way to annotate without having to use one of the tests?

Hi satvirsaggi,

the error you describe sounds like there are missing values (NA's) in your data.
But anyways, you can add custom annotations to the plot with the annotation parameter for geom_signif():

library(ggplot2)
library(ggsignif)

ggplot(iris, aes(x=Species, y=Sepal.Width)) +
  geom_boxplot() +
  geom_signif(comparisons = list(c("setosa", "versicolor"), c("versicolor", "virginica")),
              annotation = c("Comparison of left and\ncenter boxplot",
                             "Comparison of center and\nright boxplot"),
              step_increase = 0.2) +
  ylim(2, 5.5)

Created on 2020-04-16 by the reprex package (v0.3.0)

I hope this answers your question :)

If not, please provide a short reproducible example with reprex so that I better understand what the problem is.

Best, Constantin