title: Simple aggregate in R
body: <p>I try to do simple aggregate in R by this code:</p>
  
  <pre><code>test &lt;- data.frame(a=c("x","y","x","y"), 
                    b=c(2,3,4,5))
  test2 &lt;-aggregate(test, by=list(test$a),FUN="sum", na.rm=TRUE)
  </code></pre>
  
  <p>Dataset test looks like this:</p>
  
  <pre><code>  a b
  1 x 2
  2 y 3
  3 x 4
  4 y 5
  </code></pre>
  
  <p>And I want the answer test2 to be:</p>
  
  <pre><code>  a b
  1 x 6
  2 y 8
  </code></pre>
  
  <p>I get an error message:</p>
  
  <pre><code>Error in Summary.factor(c(1L, 1L), na.rm = TRUE) : 
    ‘sum’ not meaningful for factors
  </code></pre>
  
  <p>Any ideas where I went wrong?</p>