# NOT RUN {
# data frame used to illustrate tidyr::complete()
df <- wrapr::build_frame(
"group" , "item_id", "item_name", "value1", "value2" |
1 , 1 , "a" , 1L , 4L |
2 , 2 , "b" , 2L , 5L |
1 , 2 , "b" , 3L , 6L )
# columns to complete by
col_terms <- qc(group, item_id, item_name)
df %.>% complete_se(., col_terms)
df %.>% complete_se(., col_terms, fill = list(value1 = 0))
# with nesting
col_terms <- c("group", "tidyr::nesting(item_id, item_name)")
df %.>% complete_se(., col_terms)
df %.>% complete_se(., col_terms, fill = list(value1 = 0))
df %.>% complete_se(., col_terms, fill = list(value1 = 0, value2 = 0))
# }
Run the code above in your browser using DataLab