title: R: time series with duplicate time index entries
body: <p>I am a n00b at R and a n00b at stack overflow (just joined), so forgive me if I have failed to use markup (which I don't know) or missed something in the readme.</p>
  
  <p>If you don't mind, I will go through my full problem here as perhaps you might be kind enough to shed some insight into how I should best go about this!</p>
  
  <p>Stage 1<br>
  Construction of individual time-series objects for each TS1 Please find a data example below. Essentially, I am loading a csv file with multiple, irregular time-series in it (example TS1, TS2) below, so in an ideal world, I would split these into individual, irregular time-series objects (e.g. zoo?), so TS1, TS2, ... this problem was discussed here (<a href="https://stackoverflow.com/questions/8570716/r-zoo-handle-non-unique-index-entries-but-not-lose-data/25812246#25812246">R/zoo: handle non-unique index entries but not lose data?</a>) but I have tried repeatedly to use this approach, and failed.</p>
  
  <pre><code> Date TS Data 
   21/05/2014 TS1 0.95  
   17/04/2014 TS1 1.02   
   27/03/2014 TS1 0.90   
   30/01/2014 TS1 0.80   
   12/12/2013 TS1 0.70  
   18/09/2013 TS1 0.67  
   01/11/2012 TS1 0.71  
   01/11/2012 TS1 0.70  
   21/05/2014 TS2 0.47  
   20/05/2014 TS2 0.51  
   16/05/2014 TS2 0.49  
   15/05/2014 TS2 0.55  
   10/05/2014 TS2 0.63  
   07/05/2014 TS2 0.77  
  </code></pre>
  
  <p>as can be seen, the problem arises due to duplicate date index of <code>01/11/2012</code> for TS1 which causes <code>read.zoo</code> not to create my split data object.</p>
  
  <p>Stage 2<br>
  What I would then like to do is, on every irregular date, add all the data as of that date together. Since all the time-series are irregular, and with different regularity, I would like to use the prior value for a <code>TS</code>. E.g. for <code>21/05/2014</code>, this calculation in the example is straightforward as both TS1 and 2 have an entry, so the answer would be <code>0.47 + 0.95</code>. But for <code>20/05</code>, only <code>TS2</code> has an entry, so the value for <code>TS1</code> that should be used is the most recent one as of that date, i.e. the <code>17/04/2014</code> value of <code>1.02</code>, so the calculation for <code>20/05/2014</code> should be <code>0.51 + 1.02</code>. It could be that the simplest way of achieving this might be to convert each TS into a daily value, such that the previous value is used until a new data point? but this is wasteful/unnecessary for stage 3 below.</p>
  
  <p>Stage 3<br>
  Having created this aggregated data sum of all the TS', I want to do a polynomial curve-fit. I also want to differentiate this curve-fit to find the rate-of-change as of today's date predicated by this fitted curve.</p>
  
  <p>Any help would be much appreciated! I feel that repeatedly hitting my head against a wall would be more fun than doing anything more at this stage!!</p>
  
  <p>Thanks</p>
  
  <p>Updated: I now have code as follows thanks to Grothendieck.</p>
  
  <pre><code>library(scales)  
  library(zoo)  
  library(ggplot2)  
  
  f &lt;- function (z) {  
  zz &lt;- read.zoo(z, header = TRUE, split = 2, format = "%d/%m/%Y", aggregate = mean);  
  z.fill &lt;- na.locf(zz);  
  z.fill &lt;- (z.fill &gt;= 0.5) * z.fill;  
  z.fill &lt;- na.fill(z.fill,0);  
  zfill.mat = matrix(z.fill, NROW(z.fill));  
  z.sum &lt;- rowSums(zfill.mat);  
  zsum &lt;- zoo(z.sum,time(z.fill));  
  return(zsum);  
  }  
  
  DF &lt;- read.csv(file.choose(), header = TRUE, as.is = TRUE);  
  DF.S &lt;- split(DF[-2], DF[[2]]);  
  user &lt;- DF[1,2];  
  Ret &lt;- lapply(DF.S,  f);  
  </code></pre>
  
  <p>I a remaining problem:<br>
    Ret contains a list of a data frame.  I can access this by typing Ret$user, but since user varies, I need to make this dynamic.  I have tried to construct a dynamic expression e.g.:<br>
      x &lt;- paste("Ret$'",user,"'",sep = "");<br>
      plot(x)   </p>
  
  <p>but could not get this to evaluate.    </p>