Multiple factors in a dataframe are said to be connected if a model matrix based on those factors is full rank.
This function provides a formula interface to the lfe::compfactor() function to check for connectedness of the factors.
Examples
# In the data_eccleston dataframe, each pair of factors is connected.
con_check(data_eccleston, ~ row + trt)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> Levels: 1
con_check(data_eccleston, ~ col + trt)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> Levels: 1
con_check(data_eccleston, ~ row + col)
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> Levels: 1
# But all three factors are COMPLETELY disconnected into 16 groups.
con_check(data_eccleston, ~ row + col + trt)
#> [1] 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#> Levels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16