title: How can I use between function for entire columns of data.frame in R?
body: <p>I have such a dataset (<code>a3</code>), I want to select the rows of a3, the only condition is loc columns must be between Loc1 and Loc2. In my example output will be like <code>a4</code>. I use <code>for</code> loop but I want to use better functions in R such as <code>apply</code> or other</p>
  <pre><code>a3&lt;-data.frame(ID=c(7,6,7,9,3,2),
    Loc=  c(22,25,28,32,35,37),
    Loc1= c(19,20,30,38,34,41),
    Loc2= c(14,28,31,41,37,1))
  a4&lt;-data.frame(ID=c(6,3),
    Loc=c(25,35),
    Loc1=c(20,34),
    Loc2=c(28,37))
  </code></pre>