title: What is the best practice of handling time series in R?
body: <p>I am using R for some statistical analysis of time series. I have tried Googling around, but I can't seem to find any definitive answers. Can any one who knows more please point me in the right direction?</p>
  
  <p>Example:</p>
  
  <p>Let's say I want to do a linear regression of two time series. The time series contain daily data, but there might be gaps here and there so the time series are not regular. Naturally I only want to compare data points where both time series have data. This is what I do currently to read the csv files into a data frame:</p>
  
  <pre><code>library(zoo)
  apples &lt;- read.csv('/Data/apples.csv', as.is=TRUE)
  oranges &lt;- read.csv('/Data/oranges.csv', as.is=TRUE)
  apples$date &lt;- as.Date(apples$date, "%d/%m/%Y")
  oranges$date &lt;- as.Date(oranges$date, "%d/%m/%Y")
  zapples &lt;- zoo(apples$close,apples$date)
  zoranges &lt;- zoo(oranges$close,oranges$date)
  zdata &lt;- merge(zapples, zoranges, all=FALSE)
  data &lt;- as.data.frame(zdata)
  </code></pre>
  
  <p>Is there a slicker way of doing this?</p>
  
  <p>Also, how can I slice the data, e.g., select the entries in <code>data</code> with dates within a certain period?</p>