I have a zoo object called pp with daily data and 77 columns that looks like this:
X02R X03N X04K X04N X04R X06I X06N X08J X08P X09O X11O X12L X14N X15G X16K (...)
1961-01-01 8.3 5.2 3.2 0.0 8.7 5.2 15.0 7.2 11.5 13.0 0.0 4.9 0.0 2.9 6.0
1961-01-02 1.1 3.2 10.0 0.0 0.0 3.5 0.0 8.7 0.4 1.2 0.0 0.4 0.0 3.2 0.2
1961-01-03 12.0 4.2 50.5 0.0 9.0 38.5 15.0 31.7 1.7 8.7 9.0 69.2 4.2 22.2 9.2
(...)
I want to use apply.monthly
to each of the columns, so in the end I will still have 77 columns but with monthly data instead of daily data. I tried
apply.monthly(pp, FUN=sum)
but the result is a zoo object with just one column (I think is adding all the columns).
I also tried a loop:
for (i in 1:77)
{
mensal<-apply.monthly(pp[,i], FUN=sum)
}
but it also results in just one column (the 77th column). I might be able to make the loop work with some trial and error but it takes ages to compute ( I have 17897 rows and 77 columns) and I guess there is a simpler way of doing this without using loops... So if you know how, please help. Thanks!