- complete——Complete a data frame with missing combinations of data ```r df <- tibble( group = c(1:2, 1, 2), item_id = c(1:2, 2, 3), item_name = c(“a”, “a”, “b”, “b”), value1 = c(1, NA, 3, 4), value2 = 4:7 )
df
group item_id item_name value1 value2
1 1 1 a 1 4
2 2 2 a NA 5
3 1 2 b 3 6
4 2 3 b 4 7
complete(df, group, item_id, item_name)
group item_id item_name value1 value2
1 1 1 a 1 4
2 1 1 b NA NA
3 1 2 a NA NA
4 1 2 b 3 6
5 1 3 a NA NA
6 1 3 b NA NA
7 2 1 a NA NA
8 2 1 b NA NA
9 2 2 a NA 5
10 2 2 b NA NA
11 2 3 a NA NA
12 2 3 b 4 7
```
- expand——Expand data frame to include all possible combinations of values