Created
June 11, 2017 11:16
-
-
Save czeildi/6373809093cfc583ea0c909aef7e13c1 to your computer and use it in GitHub Desktop.
time series aggregation by different units in R using xts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("xts") | |
dt <- data.table( | |
day = seq.Date(as.Date('2016-07-01'), by = 'day', length.out = 180), | |
x = 1:180, | |
y = 1001:1180 | |
) | |
ts_data <- as.xts(dt) | |
monthly_sums <- apply.monthly(ts_data, apply, 2, sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment