title: subset() of a vector in R
body: <p>I've written the following function based on <code>subset()</code>, which I find handy:</p>
  
  <pre><code>ss &lt;- function (x, subset, ...) 
  {
      r &lt;- eval(substitute(subset), data.frame(.=x), parent.frame())
      if (!is.logical(r)) 
          stop("'subset' must be logical")
      x[r &amp; !is.na(r)]
  }
  </code></pre>
  
  <p>So, I can write:</p>
  
  <pre><code>ss(myDataFrame$MyVariableName, 500 &lt; . &amp; . &lt; 1500)
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>myDataFrame$MyVariableName[ 500 &lt; myDataFrame$MyVariableName 
                                  &amp; myDataFrame$MyVariableName &lt; 1500]
  </code></pre>
  
  <p>This seems like something other people might have developed solutions for, though - including something in core R I might have missed.  Anything already out there?</p>