title: How to write a loop that creates ts objects and stores them separately as such?
body: <p>I am analysing time series data of plant biomass/ rain use efficiency. I have a data set with a response variable and several factors (grazing intensities) as well as replicates for each factor (4 factors, 5 or 7 replicates) . 
  I need to create time series objects out of each individual dataset that comprises yearly data from 1981 until 2007. I have 24 individual assessments of different plots over this time.</p>
  
  <p>I am trying to write a loop for this but am failing miserably. </p>
  
  <p>The dataset is called dat. 
  PMR6yrs is the response variable.
  ID is the ID of the replicate.
  somehow it returns only one ts object in the end so I think the problem lies in storing them. </p>
  
  <p>What I tried so far is this:</p>
  
  <pre><code>tsPMR&lt;- NULL
  for (i in 1:24) {
  tsPMR6&lt;- ts(dat$PMR_6yrs[dat$ID == i],
  start = c(1981), end = c(2007), frequency = 1)
  ts&lt;-rbind(tsPMR, tsPMR6)
  }
  </code></pre>
  
  <p>Can someone assist? thanks sm </p>