title: R: Finding the intersect of two lines
body: <p>I have this simple code that creates 3 matrices and plots them: </p>
  
  <pre><code>Y=matrix(c(1,2,3,4), nrow=1)
  X1=matrix(c(2,3,3.5,4.5))
  X2=matrix(c(0.1, 0.2, 0.6, 1.1), nrow=1)
  #Plotting
  plot(X1, Y)+lines(X1,Y)
  par(new=TRUE)
  plot(X2, Y)+lines(X2,Y) + abline(v=0.4, col="red")
  </code></pre>
  
  <p>And here is the plot: 
  <a href="https://i.stack.imgur.com/IcMod.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IcMod.png" alt="enter image description here"></a></p>
  
  <p>Now, I want for the <code>X</code> value <code>0.4</code> to get all the <code>Y</code> values. The Y values are the values where the red line crosses the other two lines. 
  So there should be two values, one value <code>Y1</code> for one line and the other <code>Y2</code> value for the other line. </p>
  
  <p>Is there maybe any function that I could use to do this? I would really appreciate any suggestion how to do this.</p>