title: Alternative to function findInterval
body: <p>I'm using function findInterval to locate the position of another variables in the same row. </p>
  
  <p>Example:</p>
  
  <pre><code>set.seed(123)
  df &lt;- data.frame(x=seq(1,10,1),y=rnorm(10,1))
  val &lt;- 0.5
  
  df$x[findInterval(val,df$y, all.inside=TRUE)]
  </code></pre>
  
  <p>This give error, the vector <strong>must be sorted non-decreasingly</strong></p>
  
  <p>Is there an alternative? I have quite few columns and flipping columns back-and-forth is not that handy. </p>
  
  <p>With re-ordering of course all works:</p>
  
  <pre><code>ordered.df &lt;-df[order(df[ ,"y"], decreasing=FALSE), ]
  
  ordered.df$x[findInterval(val,ordered.df$y, all.inside=TRUE)]
  </code></pre>