title: R draw (abline + lm) line-of-best-fit through arbitrary point
body: <p>I am trying to draw a least squares regression line using <code>abline(lm(...))</code> that is also forced to pass through a particular point. I see <a href="https://stackoverflow.com/questions/7333203/linear-regression-with-explicit-intercept-in-r">this question</a> is related, but not quite what I want. Here's an example:</p>
  
  <pre><code>test &lt;- structure(list(x = c(0, 9, 27, 40, 52, 59, 76), y = c(50, 68, 
  79, 186, 175, 271, 281)), .Names = c("x", "y"))
  
  # set up an example plot
  plot(test,pch=19,ylim=c(0,300),
       panel.first=abline(h=c(0,50),v=c(0,10),lty=3,col="gray"))
  
  # standard line of best fit - black line
  abline(lm(y ~ x, data=test))
  
  # force through [0,0] - blue line
  abline(lm(y ~ x + 0, data=test), col="blue")
  </code></pre>
  
  <p>This looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/jk6I1.png" alt="enter image description here"></p>
  
  <p>Now how would I go about forcing a line through the marked arbitrary point of <code>(x=10,y=50)</code> while still minimising the distance to the other points?</p>
  
  <pre><code># force through [10,50] - red line
  ??
  </code></pre>