title: Using tapply on data with NAs
body: <p>I have a data column (Percent.Plant.Parasites) that has some NAs.  I want to take the mean of this data sorted by factor "Stage" (ie stage1 Mean=x, stage2 Mean=y, etc).  I tried doing this using </p>
  
  <pre><code>tapply(rawdata$Percent.Plant.Parasites, rawdata$Stage, mean)
  </code></pre>
  
  <p>However, I get NAs because there are NAs in the data.  I don't believe there is an na.rm option for tapply (is there?), so I tried to calculate the mean of each individual stage factor using:</p>
  
  <pre><code>mean(subset(rawdata,subset=Stage=="stage1")$Percent.Plant.Parasites, na.rm=TRUE)
  </code></pre>
  
  <p>to no avail.  Instead I got the error: </p>
  
  <pre><code>In mean.default(subset(rawdata, subset = Stage == "Kax")$Percent.Plant.Parasites,  :
  </code></pre>
  
  <p>argument is not numeric or logical: returning NA</p>
  
  <p>However, when I do:</p>
  
  <pre><code>typeof(subset(rawdata,subset=Stage=="Kax")$Percent.Plant.Parasites)
  </code></pre>
  
  <p>I get <code>integer</code></p>
  
  <p>Any ideas where I'm going wrong?  </p>
  
  <p>Thanks.</p>