title: by() giving error when applying mean function over a data frame. What's happening?
body: <p>I am trying to learn <code>by()</code> in R(3.0.1) . 
  This is what I am doing.</p>
  
  <ol>
  <li>Open R</li>
  <li><code>attach(iris)</code></li>
  <li><code>head(iris)</code></li>
  <li><code>by(iris[,1:4] , Species , mean)</code></li>
  </ol>
  
  <p>This is what I am getting</p>
  
  <pre><code>&gt; by(iris[,1:4] , Species , mean)
  
  Species: setosa
  [1] NA
  ------------------------------------------------------------ 
  Species: versicolor
  [1] NA
  ------------------------------------------------------------ 
  Species: virginica
  [1] NA
  Warning messages:
  1: In mean.default(data[x, , drop = FALSE], ...) :
    argument is not numeric or logical: returning NA
  
  2: In mean.default(data[x, , drop = FALSE], ...) :
    argument is not numeric or logical: returning NA
  
  3: In mean.default(data[x, , drop = FALSE], ...) :
    argument is not numeric or logical: returning NA
  </code></pre>