Hi I am trying to use split() to split a xts data set into weeks, but the result seems not right. original data is as following:
> head(xec) Open High Low Close mean 2011-02-28 112.34 113.34 111.96 112.87 112.6275 2011-03-01 112.89 113.71 112.75 112.80 113.0375 2011-03-02 112.75 113.56 112.50 113.54 113.0875 2011-03-03 113.50 115.08 113.10 115.05 114.1825 2011-03-04 115.16 115.97 114.85 115.06 115.2600 2011-03-07 115.21 115.26 114.55 114.85 114.9675 ... and I did the split() as following > head(split(x=xec,f="weeks")) [[1]] Open High Low Close mean 2011-02-28 112.34 113.34 111.96 112.87 112.6275 [[2]] Open High Low Close mean 2011-03-01 112.89 113.71 112.75 112.80 113.0375 2011-03-02 112.75 113.56 112.50 113.54 113.0875 2011-03-03 113.50 115.08 113.10 115.05 114.1825 2011-03-04 115.16 115.97 114.85 115.06 115.2600 2011-03-07 115.21 115.26 114.55 114.85 114.9675 ... the "2011-02-28" is the Monday but not being grouped with the other days in that week, which makes the second groups begin from Tuesday ("2011-03-01"). I want it to be as following [[1]] Open High Low Close mean 2011-02-28 112.34 113.34 111.96 112.87 112.6275 2011-03-01 112.89 113.71 112.75 112.80 113.0375 2011-03-02 112.75 113.56 112.50 113.54 113.0875 2011-03-03 113.50 115.08 113.10 115.05 114.1825 2011-03-04 115.16 115.97 114.85 115.06 115.2600 [[2]] Open High Low Close mean 2011-03-07 115.21 115.26 114.55 114.85 114.9675 ... Could anyone please give some advice? Thanks in advance. Seimizu Joukan ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.