title: Strange error message whatever way I try to aggregate mean in R
body: <p>I am making a model to measure Brand and drivers. I do that by using a survey and factor analysis. To validate the stability of the model I have made a routine to bootstrap the whole survey. THe problem is when I try to aggregate. I have used the package (hmisc) and (doBy). Whatever I have tried it did not work. Now, teh problem is that only mean does not work. Standard devation works, max works etc. but mean produces the same error. 
  Again, I am a beginner in R, so please be patient. I have probably failed somewhere.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>agg&lt;-summaryBy(t1+t2+t3+t4 ~ Brand, data = BTaggtot, 
       FUN = function(x) { c(m = mean(x), s = sd(x)) } )
  
  ##Warning message: In `[&lt;-.factor`(`*tmp*`, ri, value = "") :   invalid factor level, NA generated
  
  ##  Brand   t1.m    t1.s    t2.m    t2.s    t3.m    t3.s    t4.m    t4.s
  ##1 x   NA  0.06916467  NA  0.06445095  NA  0.15462236  NA  0.14408303
  ##2 y   NA  0.12698044  NA  0.11589796  NA  0.11166112  NA  0.09784066
  ##3 z   NA  0.27728356  NA  0.31683492  NA  0.28952003  NA  0.25356425
  ##4 a   NA  0.06464727  NA  0.06261208  NA  0.13125807  NA  0.14010969
  ##5 b   NA  0.13333295  NA  0.13995869  NA  0.07081607  NA  0.05426994
  ##6 c   NA  0.17935163  NA  0.15829171  NA  0.17706202  NA  0.16386928
  </code></pre>
  
  <p>The raw data file, which in itself is an aggregate from the bootstrapping data:</p>
  
  <pre><code>    BTaggtot &lt;- 
      structure(list(Brand = c("x", "y", "z", "a", 
      "b", "c", "x", "y", "z", "a", 
  
  NA)), .Names = c("Brand", "t1", "t2", "t3", "t4"), row.names = c(NA, 
  61L), class = "data.frame") 
  
  BTaggtot$t1 &lt;- as.numeric(as.character(BTaggtot$t1)) 
  BTaggtot$t2 &lt;- as.numeric(as.character(BTaggtot$t2)) 
  BTaggtot$t3 &lt;- as.numeric(as.character(BTaggtot$t3)) 
  BTaggtot$t4 &lt;- as.numeric(as.character(BTaggtot$t4)) 
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>##Brand t1.m    t1.s    t2.m    t2.s    t3.m    t3.s    t4.m    t4.s
  ##1 NA  NA  NA  NA  NA      NA  NA  NA
  ##2 x   0.19568792  0.011451510 0.04804116  0.014245490 0.158772048  0.09756682 -0.08942659 0.09520222
  ##3 y   0.33358223  0.013269567 -0.05392707 0.014502275 0.048156816 0.06733359  -0.12412978 0.05822441
  ##4 z   0.14213090  0.057348103 0.21348340  0.081216793 0.247131971 0.06523768  0.15880299  0.07527778
  ##5 a   0.05697128  0.011903945 -0.06825173 0.010993725 -0.128795343    0.08287723  -0.33948934 0.08403221
  ##6 b   0.33710639  0.006427330 -0.10283455 0.009699357 0.003772128 0.02699491  0.07900255  0.02691813
  ##7 c   -0.47443412 0.008258243 0.08995661  0.010455134 -0.041590502    0.11071262  0.23812028  0.10615406
  </code></pre>