title: How to calculate the overlap between 2 dataset distribution
body: <p>Hi How can calculate the overlapping area between 2 columns ( or 2 subsets of a column) in R.
  Please see the example data below:</p>
  <pre><code>set.seed(1234)
  df &lt;- data.frame(
    Data=factor(rep(c(&quot;D1&quot;, &quot;D2&quot;), each=200)),
    weight=round(c(rnorm(200, mean=55, sd=5),
                   rnorm(200, mean=65, sd=5)))
  )
  
  library(ggplot2)
  plot &lt;- ggplot(df, aes(weight,fill = Data))+
    geom_density() 
  plot
  </code></pre>
  <p>This results in the below plot. I am wondering, how to color the overlapping area and calculate the overlapping coefficient (OVL) similar to what is done <a href="https://www.r-bloggers.com/2014/01/calculating-the-overlap-of-two-normal-distributions-using-monte-carlo-integration/" rel="nofollow noreferrer">here</a> Using Monte Carlo Integration?
  Please note that the link (and example above) provided uses parametric distribution while I am asking if I have a dataset of observed values.</p>
  <p><a href="https://i.stack.imgur.com/QHKlB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QHKlB.png" alt="enter image description here" /></a></p>