title: Easiest way to subset within a multidimensional range?
body: <p>I apologize in advance if this has been asked before, or if I have missed something obvious.</p>
  
  <p>I have two data sets, 'olddata' and 'newdata'</p>
  
  <pre><code>set.seed(0)
  olddata &lt;- data.frame(x = rnorm(10, 0,5), y = runif(10, 0, 5), z = runif(10,-10,10))
  newdata &lt;- data.frame(x = -5:5, z = -5:5)
  </code></pre>
  
  <p>I create a model from the old data, and want to predict values from the new data</p>
  
  <pre><code>mymodel &lt;- lm(y ~ x+z, data = olddata)
  predict.lm(mymodel, newdata)
  </code></pre>
  
  <p>However, I'd like to restrict the range of variables in 'newdata' to the range of variables on which the model was trained.</p>
  
  <p>of course I could do this:</p>
  
  <pre><code> newnewdata &lt;- subset(newdata, 
                        x &lt; max(olddata$x) &amp; x &gt; min(olddata$x) &amp;
                        z &lt; max(olddata$z) &amp; z &gt; max(olddata$z))
  </code></pre>
  
  <p>But this gets intractable over many dimensions. Is there a less repetitive way to do this? </p>