title: How to add significance bar between subgroups of box plot
body: <p>I would like to make a wilcox test and add a significance bar for each group in the boxplot (not between groups). I.e. comparing subgroups ("0", "1") at time 2, 6, and 14.
  This is what I have so far:</p>
  
  <p><strong>WS = time<br/>
  DV = effect<br/>
  count = subgroup ("0" or "1")</strong></p>
  
  <pre><code>p &lt;- ggplot(data, aes(x=WS, y=DV, group=count))
  p &lt;- p + geom_boxplot(aes(fill=factor(count), group=interaction(WS, count)))
  p &lt;- p + stat_summary(fun.y=median, geom="smooth", aes(group=factor(count), color =factor(count)))
  p &lt;- p + scale_x_continuous(breaks = c(2,6,14))
  p
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/UrsQG.jpg" rel="nofollow noreferrer">Output from code</a></p>
  
  <p>When adding</p>
  
  <pre><code>p &lt;- p + geom_signif(comparisons = list(c("0", "1")),
                map_signif_level=TRUE,test='wilcox.test')
  </code></pre>
  
  <p>to the above, I get the following error: </p>
  
  <pre><code>Error in f(...) : 
    Can only handle data with groups that are plotted on the x-axis
  </code></pre>
  
  <p>I assume that a comparison can only be made on if the data is on the x-axis. However, I want to keep the plot pretty much as it is right now, with time 2, 6 and 14 on the x-axis. How can I solve this?</p>