0

I'm trying to aggregate my data using the apply.weekly() function in xts. However, when I do so, one week has 8 days rather than 7 days. Here is the output of apply.weekly() function:

2013-06-01 0.0000000
2013-06-08 0.5718182
2013-06-15 0.3365385
2013-06-22 0.7534615
2013-06-30 0.7467568
2013-07-07 0.7996000
2013-07-13 0.2811111
2013-07-21 0.3743750
2013-07-28 0.2142857
2013-08-04 0.5664516
2013-08-11 0.5790000
2013-08-18 0.3404255
2013-08-24 0.5240625
2013-08-31 1.1986207
2013-09-06 4.8233333

As you can see, in above output the week between "2013-06-22" and "2013-06-30" has 8 days and it changes all the consecutive indexes in my program. Interestingly, the week between "2013-08-18" and "2013-08-24" has only 6 days.

Any idea how can I fix this?

EDIT: here is a glimpse of the data

index       price
2013-06-01  0.000
2013-06-06  5.290
2013-06-08  1.000
2013-06-13  6.750
2013-06-15  1.000
2013-06-15  1.000
2013-06-17  1.000
2013-06-19  1.000
2013-06-20  1.000
2013-06-21  16.590
2013-06-24  5.990
2013-06-25  4.650
2013-06-26  1.000
2013-06-26  11.990
2013-06-27  1.000
2013-06-29  1.000
2013-06-29  1.000
2013-06-30  1.000

After loading this data, I'm just trying to use the following command:

price_weekly <- apply.weekly(dt$price,mean)
Yaser Kenesh
  • 81
  • 1
  • 9
  • 3
    Please post the code that leads to the problem. – Rich Scriven Oct 15 '14 at 19:24
  • Without a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), all we can do is guess about what the problem may be... – Joshua Ulrich Oct 15 '14 at 20:30
  • A "glimpse of the data" is not a reproducible example. I'm willing to help you, but you have to give me more information, as is described in the link I provided in my previous comment. – Joshua Ulrich Oct 16 '14 at 05:49

0 Answers0