title: add p-values of Pearson's chi-squared test to facet ggplots
body: <p>I compare categorical data from three different groups. </p>
  
  <p>I wonder if it is possible to easily add p-values of chi-squared tests to facet ggplots (since I am analyzing a big data set). I just read that there is a marvelous way to do so when comparing means <a href="https://www.r-bloggers.com/add-p-values-and-significance-levels-to-ggplots/" rel="nofollow noreferrer">https://www.r-bloggers.com/add-p-values-and-significance-levels-to-ggplots/</a>. However, I could not find a solution for other tests (like the chisq.test in my case).</p>
  
  <pre><code>d.test &lt;- data.frame(
    results = sample(c("A","B","C"), 30, replace =TRUE),
    test = sample(c("test1", "test2","test3"), 30, replace = TRUE)
  )
  
  chisq.test(d.test$results,d.test$test)
  
  ggplot(d.test, aes(results) ) +
    geom_bar() + facet_grid(test ~ .)
  </code></pre>
  
  <p>Many thanks for your help! ;D</p>