[datatable-help] Join with roll
Sterkens, Patrick [JRDBE]
PSTERKEN at its.jnj.com
Tue Sep 25 10:49:16 CEST 2012
Hi Matthew,
A probably trivial problem, but cannot seem to sort this one out.
I have a similar problem as described in SO
9http://stackoverflow.com/questions/10438969/fastest-way-to-add-rows-for
-missing-values-in-a-data-frame): need to insert missing time points
into a data.table and set the parameter value to NA while padding the
grouping variables.
I tried your solution but...that the timepoint that is missing in my
data set is the first time point, therefore roll=TRUE does not work and
I get NA's where I would like to get values for the grouping variables
helpdt=data.table(cbind(expand.grid(Hr=c(1,2,4),Rep=c("a","b","c"),COND=
c("L","M","H")),ID=rep(1:9,each=3),Value=9090))
setkey(helpdt,ID,Hr)
helpdt[CJ(unique(ID),c(0,1,2,4)),roll=TRUE]
Thanks
Patrick
More information about the datatable-help
mailing list