描述

    将数据框按照指定列,进行完整组合 将隐式缺失值转换为显式缺失值。将构造列值的所有组合(应该是惟一的)。其他列将用NAs或常数值填充。

    Usage

    complete_dt(.data, …, fill = NA)

    Value

    data.table

    1. df <- data.table(
    2. group = c(1:2, 1),
    3. item_id = c(1:2, 2),
    4. item_name = c("a", "b", "b"),
    5. value1 = 1:3,
    6. value2 = 4:6
    7. )
    8. df %>% complete_dt(item_id,item_name)
    9. df %>% complete_dt(item_id,item_name,fill = 0)
    10. df %>% complete_dt("item")
    11. df %>% complete_dt(item_id=1:3)
    12. df %>% complete_dt(item_id=1:3,group=1:2)
    13. df %>% complete_dt(item_id=1:3,group=1:3,item_name=c("a","b","c"))
    1. ![](https://cdn.nlark.com/yuque/0/2020/png/1118538/1597657709938-0bf38837-49db-47be-91a5-882f122ee910.png)