Detect contingency table type for a pair of categorical variables
Source:R/detect_type.R
detect_type.RdFor a given pair of columns, this function determines whether the
cross-tabulation yields a 2x2 or a larger (n x m) contingency table,
after removing rows with missing values in either column (pairwise
deletion). This drives the dispatch between the phi coefficient and
Cramer's V in effect_size.
Value
A character string: "2x2" if both variables have exactly
two levels observed in the pairwise-complete data, or "RxC"
otherwise.
Details
Level counts are computed on the pairwise-complete subset, not on the full vector. This means that a variable with three levels in the full data may be classified as having two levels for a specific pair if one level is entirely missing when the other variable is observed.