I was looking for a way to fill a time series data set by time, per group. The very very inefficient way I was using was to split
the data set per group and app
It appears that data.table
is really much faster than the tidyverse
option. So merely translating the above into data.table
(compliments of @Frank) completed the operation in little under 3 minutes.
library(data.table)
mDT = setDT(d1)[, .(grp = seq(min(grp), max(grp), by = "hour")), by = source]
new_D <- d1[mDT, on = names(mDT)]
new_D <- new_D[, cnt := replace(cnt, is.na(cnt), 0)] #If needed