Adds rows to the input data table to include any combinations of .x and .y that are not already present. All other columns (if any) are set to NA

bind_missing_combs(df, .x, .y)

Arguments

df

input data table

.x, .y

names of the columns for which to add missing comparisons

Value

a data table with the new rows

Examples

df <- data.frame( a = c("A", "B"), b = c("C", "A"), untouched = c(1, 2), stringsAsFactors = FALSE ) df
#> a b untouched #> 1 A C 1 #> 2 B A 2
bind_missing_combs(df, a, b)
#> a b untouched #> 1 A C 1 #> 2 B A 2 #> 3 A A NA #> 4 C A NA #> 5 A B NA #> 6 B B NA #> 7 C B NA #> 8 B C NA #> 9 C C NA