Turns implicit missing values into explicit missing values.

complete(.df, ..., fill = list(), .by = NULL)

Arguments

.df

A data.frame or data.table

...

Columns to expand

fill

A named list of values to fill NAs with.

.by

Columns to group by

Examples

df <- data.table(x = 1:2, y = 1:2, z = 3:4)

df %>%
  complete(x, y)
#> # A tidytable: 4 × 3
#>       x     y     z
#>   <int> <int> <int>
#> 1     1     1     3
#> 2     1     2    NA
#> 3     2     1    NA
#> 4     2     2     4

df %>%
  complete(x, y, fill = list(z = 10))
#> # A tidytable: 4 × 3
#>       x     y     z
#>   <int> <int> <int>
#> 1     1     1     3
#> 2     1     2    10
#> 3     2     1    10
#> 4     2     2     4