title: Add a median "best fit line" to a scatter plot in r
body: <p>I would like to add an empirical line of best fit to a scatter plot that is based on the median y for a range of x, eg at x=0.105 would be the y line of the median y's for x in the range 0.100 to 0.110, at x=0.115 would be the y line of the median y's for x in the range 0.110 to 0.120, etc. These y line points will be joined up. These x's are just for illustration, I'd like to be flexible in their choice. (I do not want a parametric fit, thanks)</p>
  <p>This simulates some data:</p>
  <pre><code>x&lt;-0.1+runif(n=1000,min=0,max=1)
  y&lt;-1/x+runif(n=1000,min=0,max=1)*(1-x)*5
  plot(x,y)
  </code></pre>
  <p>Here is a mock up of the median line in orange.</p>
  <p><a href="https://i.stack.imgur.com/XITt1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XITt1.jpg" alt="mock up of desired plot" /></a></p>