Quantcast
Viewing latest article 7
Browse Latest Browse All 57

Filtering a xts object from one year to the next

If I have a 10-year daily xts time series, starting on 1985-01-01 and ending on 1994-12-31, how can I calculate the sum of values for the interval starting on Nov 1 and ending on Mar 31 of the next year, through out the series?

dates <- seq(from = as.Date("1985-01-01"), to = as.Date("1994-12-31"), by = 1)data <- rnorm(length(dates))my.ts <- xts(x=data, order.by=dates)

I need to get

my.ts2[1] = sum(my.ts[1985-11-01 to 1986-03-31])my.ts2[2] = sum(my.ts[1986-11-01 to 1987-03-31])my.ts2[3] = sum(my.ts[1987-11-01 to 1988-03-31])and so on

Note: There are no Feb-29 in the original time series.


Viewing latest article 7
Browse Latest Browse All 57

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>