描述
将数据框按照指定列,进行完整组合 将隐式缺失值转换为显式缺失值。将构造列值的所有组合(应该是惟一的)。其他列将用NAs或常数值填充。Usage
complete_dt(.data, …, fill = NA)
Value
data.table
df <- data.table(
group = c(1:2, 1),
item_id = c(1:2, 2),
item_name = c("a", "b", "b"),
value1 = 1:3,
value2 = 4:6
)
df %>% complete_dt(item_id,item_name)
df %>% complete_dt(item_id,item_name,fill = 0)
df %>% complete_dt("item")
df %>% complete_dt(item_id=1:3)
df %>% complete_dt(item_id=1:3,group=1:2)
df %>% complete_dt(item_id=1:3,group=1:3,item_name=c("a","b","c"))
![](https://cdn.nlark.com/yuque/0/2020/png/1118538/1597657709938-0bf38837-49db-47be-91a5-882f122ee910.png)