Skip to content
Prev 316739 / 398506 Next

Split xts data set into weeks

On Sun, Feb 3, 2013 at 6:57 AM, Seimizu Joukan <saimizi at gmail.com> wrote:
Indeed, well done and much appreciated.
Looking at args(split.xts) I think you actually do want split(..., f =
) here, not split(..., frequency = ), which would ignore and default
to months.


I get the following for res1, running R-Devel on OS X 10.6.8:
[[1]]
             Open   High    Low  Close
2011-02-27 112.34 113.34 111.96 112.87

[[2]]
             Open   High    Low  Close
2011-02-28 112.89 113.71 112.75 112.80
2011-03-01 112.75 113.56 112.50 113.54
2011-03-02 113.50 115.08 113.10 115.05
2011-03-03 115.16 115.97 114.85 115.06
2011-03-06 115.21 115.26 114.55 114.85

[[3]]
             Open   High    Low  Close
2011-03-07 114.84 115.22 114.55 114.93
2011-03-08 114.93 115.24 114.75 115.09
2011-03-09 115.05 115.24 114.20 114.28
2011-03-10 114.46 114.98 112.92 113.92

so I think it's likely a timezone issue. Try setting

indexTZ(tmp) <- "GMT"

or something similar and giving it another shot.

You might also want to move to the R-SIG-Finance class where the
authors of xts are more frequently seen.

It might also help to report Sys.timezone() in addition to your
specific linux distro.

Cheers,

MW