I have a time series of four years data. And I want to do a for loop operation over the months. I am using 'xts' package. This is how first four rows of my original data frame ('obs') looks like
t V2 V3 V4 V5 V6 V7 V8 V9
1 2009-09-25 18:00:00 32.965 32.965 33.525 32.965 32.965 32.965 32.965
2 2009-09-26 06:00:00 32.965 32.965 32.965 32.965 31.853 32.407 31.301
3 2009-09-26 18:00:00 31.853 31.853 31.853 32.407 31.301 30.752 31.301
4 2009-09-27 06:00:00 29.687 29.194 30.752 28.707 27.750 27.279 27.279
First I split the data series in to monthly data using
obsl <- split(obs, f = "months", drop=FALSE, k = 1)
Now I have all monthly data series in a list. I want to call each monthly list using obsl[i] 'i' being the 'i'th month list and convert this list in to matrix of monthly data series. Foe eg this is the output of obsl[2] and it's a list
V2 V3 V4 V5 V6 V7 V8 V9
2009-10-01 06:00:00 25.900 25.900 25.900 26.355 26.814 25.900 25.900 25.451
2009-10-01 18:00:00 25.900 25.900 25.900 25.007 25.007 25.007 25.900 25.451
2009-10-02 06:00:00 25.007 25.007 25.007 25.007 25.007 25.007 25.007 25.007
2009-10-02 18:00:00 25.007 25.007 25.007 25.007 25.900 25.007 24.136 24.569
2009-10-31 18:00:00 36.950 37.531 38.115 38.702 39.884 40.480 41.681 42.286
But I am not sure if it's the correct and elegant way of doing it. Also I don't know how to convert the list to a matrix with the original matrix form (i.e first column-time stamp and the rest - numeric). Can anybody help?