0

I have looked at many of the questions on here that relate to aggregating time series data, but I can't seem to solve my problem. My data looks like this:

                    Pings Adult Entertainment Female Information Lifestyle Male MAV.TV MeTV News Pursuit Sports Young Adult
2015-01-05 07:30:00     1     0             0      0           0         0    0      0    0    0       0      0           0
2015-01-05 07:43:00     1     0             0      0           0         0    0      0    0    0       0      0           0
2015-01-05 07:44:00     1     0             0      0           0         0    0      0    0    0       0      0           0
2015-01-05 07:59:00     5     0             0      0           0         0    0      0    0    0       0      0           0
2015-01-05 08:02:00     1     0             0      0           0         0    0      0    0    0       0      0           0
2015-01-05 08:17:00     1     0             0      0           0         0    0      0    0    0       0      0           0

and I want to find a way to roll this up in 15 minute increments, summing every row. I've tried merge and cut and aggregate and na.locf methods, but none of them quite work. I've also tried period.apply but I can't seem to get that to work.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Moderat
  • 1,462
  • 4
  • 17
  • 21
  • 1
    The `cut.POSIXt` function has the option of specifying an interval along the lines of `breaks="15 min"`. Seems like using that approach would be close to trivial if used in combination with `aggregate`. – IRTFM Mar 04 '15 at 22:01
  • Yes I just figured it out, thanks BondedDust – Moderat Mar 04 '15 at 22:09

1 Answers1

0

For timebreak = ISOdatetime(2015, 1, 5, 7, 0, 0) + (seq(0,7)*15*60), I used fac = cut(time(data), breaks = timebreak) and then aggregate(data, by = fac, FUN = sum)

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Moderat
  • 1,462
  • 4
  • 17
  • 21