title: Filter rows from dataframe by std devs from mean on each variable
body: <p>Using the iris data set as an example, how can I filter the rows from the dataframe by checking, at each column, if that row's variable is within a certain number of std devs from the mean for that column.  I can do this with a for-loop, but I believe R has a better, faster way to wrangle this data.  I've looked into <code>dply::filter</code> but that seems to only work nicely for one variable.  What I want to do is to look at the first column, subset the data based on std_devs from the mean, and use that subset and apply the same function for the next column</p>
  
  <pre><code>n &lt;- names(iris[1:4]) #get the non-factors
  a &lt;- iris[n]
  lapply(a, function(x) a &lt;- subset(a, x &gt;= mean(x) - sd(x) &amp; x &lt;= mean(x) + sd(x)))
  </code></pre>
  
  <p>This returns some type of list (with a data frame embedded in it) the size of iris[n] for <strong>each column</strong>. The results  from the first set don't seem to carry over to the next.  Also, at the end of the process, <code>a</code> doesn't seem to be changed.  I don't think you can modify the variable as <code>lapply</code> is doing work on it, but if someone can point me in the right direction that would be very helpful - thank you.</p>