title: R - locate intersection of two curves
body: <p>There are a number of questions in this forum on locating intersections between a fitted model and some raw data. However, in my case, I am in an early stage project where I am still evaluating data.</p>
  
  <p>To begin with, I have created a data frame that contains a ratio value whose ideal value should be 1.0. I have plotted the data frame and also used <code>abline()</code> function to plot a horizontal line at <code>y=1.0</code>. This horizontal line and the plot of ratios intersect at some point. </p>
  
  <pre><code>plot(a$TIME.STAMP, a$PROCESS.RATIO,
       xlab='Time (5s)',
       ylab='Process ratio',
       col='darkolivegreen',
       type='l')
  abline(h=1.0,col='red')
  </code></pre>
  
  <p>My aim is to locate the intersection point, say <code>x</code> and draw two vertical lines at <code>x±k</code>, as <code>abline(v=x-k)</code> and <code>abline(v=x+k)</code> where, k is certain band of tolerance.</p>
  
  <p>Applying a grid on the plot is not really an option because this plot will be a part of a multi-panel plot. And, because ratio data is very tightly laid out, the plot will not be too readable. Finally, the <code>x±k</code> will be quite valuable in my discussions with the domain experts. </p>
  
  <p>Can you please guide me how to achieve this?</p>