title: Rolling standard deviation for every 5th day in R
body: <p>I have a time series dataframe which looks like</p>
  
  <pre><code>2014-02-05 2014-02-06 2014-02-07 2014-02-12 2014-02-14 2014-02-17 2014-02-18 2014-02-19 ......
      0.0379    -0.0008     0.0352     0.0379     0.0392     0.0173     0.0360     0.0371
  </code></pre>
  
  <p>I want to compute moving standard deviation for every 5th day data from this list in R. What I mean is that, I wish to select a sample in the form such that sample1[1] = 2014-02-05,  0.0379 , sample1[2] =2014-02-12, 0.0379.....and then find the std dev of this sample and then use a rolling standard deviation to move on to the next date i.e. sample2[1] =2014-02-06,  -0.0008 , sample2[2] =2014-02-12, 0.0379 and find the standard deviation of this list and so on. Since day available is irregular, I cannot use seq(1:l, by = ). In rollapply, the function would take every consecutive numbers to compute the standard deviation. Is there a way to sample every 5th day data from this list in an efficient way, or modify the standard deviation function somehow, to make it select every 5th day data and then compute the standard deviation on the available data. Any suggestion in this regard will be highly appreciated.</p>