Created
April 23, 2013 15:37
-
-
Save ijlyttle/5444643 to your computer and use it in GitHub Desktop.
using ddply seems to wipe out the "Duration"
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(plyr) | |
library(lubridate) | |
n_intvl <- 48 | |
dur_intvl <- dseconds(900) | |
intvl_15min <- data.frame( | |
start = ymd("2001-01-01", tz="America/Chicago") + seq(0, n_intvl-1)*dur_intvl, | |
dur = rep(dur_intvl, n_intvl) | |
) | |
str(intvl_15min) | |
# note that dur has class Duration | |
intvl_hour <- ddply( | |
.data = mutate(intvl_15min, start=floor_date(start, "hour")), | |
.variables = .(start), | |
.fun = summarize, | |
dur = sum(dur) | |
) | |
str(intvl_hour) | |
# note that dur has class numeric |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment