title: Aggregating daily content
body: <p>I've been attempting to aggregate (some what erratic) daily data. I'm actually working with csv data, but if i recreate it - it would look something like this:</p>
  
  <pre><code>library(zoo)
  
  dates &lt;- c("20100505", "20100505", "20100506", "20100507")
  val1 &lt;- c("10", "11", "1", "6")
  val2 &lt;- c("5", "31", "2", "7")
  
  x &lt;- data.frame(dates = dates, val1=val1, val2=val2)
  z &lt;- read.zoo(x, format = "%Y%m%d")
  </code></pre>
  
  <p>Now i'd like to aggregate this on a daily basis (notice that some times there are >1 datapoint for a day, and sometimes there arent. </p>
  
  <p>I've tried lots and lots of variations, but i cant seem to aggregate, so for instance this fails:</p>
  
  <pre><code>aggregate(z, as.Date(time(z)), sum)
  # Error in Summary.factor(2:3, na.rm = FALSE) : sum not meaningful for factors
  </code></pre>
  
  <p>There seems to be a lot of content regarding aggregate, and i've tried a number of versions  but cant seem to sum this on a daily level. I'd also like to run cummax and cumulative averages in addition to the daily summing. </p>
  
  <p>Any help woudl be greatly appreciated.</p>
  
  <p><strong><em>Update</em></strong></p>
  
  <p>The code I am actually using is as follows:</p>
  
  <pre><code>z &lt;- read.zoo(file = "data.csv", sep = ",", header = TRUE, stringsAsFactors = FALSE, blank.lines.skip = T, na.strings="NA", format = "%Y%m%d");
  </code></pre>
  
  <p>It seems my (unintentional) quotation of the numbers above is similar to what is happening in practice, because when I do:</p>
  
  <pre><code>aggregate(z, index(z), sum)
  #Error in Summary.factor(25L, na.rm = FALSE) : sum not meaningful for factors
  </code></pre>
  
  <p>There a number of columns (100 or so), how can i specify them to be as.numeric automatically ? (<code>stringAsFactors = False</code> doesnt appear to work?)</p>