Fill in missing rows with R data.table
With help from @akrun and @eddi, here's the idiomatic (?) way:
mycols = c("description","date","location")
setkeyv(DT0,mycols)
DT1 <- DT0[J(do.call(CJ,lapply(mycols,function(x)unique(get(x)))))]
# alternately: DT1 <- DT0[DT0[,do.call(CJ,lapply(.SD,unique)),.SDcols=mycols]]
The identifier
column is missing for the new rows, but can be filled:
setkey(DT1,description)
DT1[unique(DT0[,c("description","identifier")]),identifier:=i.identifier]