title: Area between the two curves
body: <p>I have two sets of data</p>
  
  <p>I had plotted two probability density functions. Now I want the area between the two probability density functions, which are in certain x range.</p>
  
  <p>I tried to integrate the area, trapezoidal rule etc:</p>
  
  <p><a href="https://stackoverflow.com/questions/48752035/calculating-the-area-between-a-curve-and-a-straight-line-without-finding-the-fun?rq=1">Calculating the area between a curve and a straight line without finding the function</a></p>
  
  <p><a href="https://stackoverflow.com/questions/40083837/error-calculating-the-area-between-two-lines-using-integrate">Error calculating the area between two lines using &quot;integrate&quot;</a></p>
  
  <p><a href="https://stackoverflow.com/questions/24742677/how-to-measure-area-between-2-distribution-curves-in-r-ggplot2">How to measure area between 2 distribution curves in R / ggplot2</a></p>
  
  <p>but all are in vain.</p>
  
  <p>Here is the link to the data i am working on.</p>
  
  <p><a href="https://sheet.zoho.com/sheet/editor.do?doc=1ff030ea1af35f06f8303927d7ea62b3c4b04bdae021555e8cc43ed0569cb2aaceb26368f93db4d15ac66cf7662d9a7873e889e1763139a49ffd68e7843e0b44" rel="nofollow noreferrer">https://sheet.zoho.com/sheet/editor.do?doc=1ff030ea1af35f06f8303927d7ea62b3c4b04bdae021555e8cc43ed0569cb2aaceb26368f93db4d15ac66cf7662d9a7873e889e1763139a49ffd68e7843e0b44</a></p>
  
  <pre><code>dens.pre=density(TX/10)
  dens.post=density(TX30/10)`
  plot(dens.pre,col="green")
  lines(dens.post,col="red")
  
  locator()
  #$x
  #[1] 18.36246
  
  #$y
  #[1] 0.05632428
  
  abline(v=18.3,col="red")
  </code></pre>
  
  <p>Finding the area between the two curves for X > 18.3.</p>
  
  <p>Area between the curves:
  <a href="https://i.stack.imgur.com/mPhtM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mPhtM.png" alt="enter image description here"></a></p>