is_matrix verifies that mx is a
valid 2x2 matrix (i.e., a numeric contingency table).
Details
is_matrix is more restrictive than is.matrix,
as it also requires that mx is.numeric,
is.table, nrows(mx) == 2, and ncols(mx) == 2.
References
Neth, H., Gradwohl, N., Streeb, D., Keim, D.A., & Gaissmaier, W. (2021). Perspectives on the 2×2 matrix: Solving semantically distinct problems based on a shared structure of binary contingencies. Frontiers in Psychology, 11, 567817. doi: doi:10.3389/fpsyg.2020.567817
See also
Other verification functions:
is_complement(),
is_extreme_prob_set(),
is_freq(),
is_integer(),
is_perc(),
is_prob(),
is_suff_prob_set(),
is_valid_prob_pair(),
is_valid_prob_set(),
is_valid_prob_triple()
Examples
is_matrix(1:4)
#> is_matrix: mx is no matrix.
#> [1] FALSE
is_matrix(matrix("A"))
#> is_matrix: mx is no contingency table.
#> [1] FALSE
is_matrix(matrix(1:4))
#> is_matrix: mx is no contingency table.
#> [1] FALSE
is_matrix(as.table(matrix(1:4, nrow = 1, ncol = 4)))
#> is_matrix: mx does not have 2 rows.
#> [1] FALSE
is_matrix(as.table(matrix(1:4, nrow = 4, ncol = 1)))
#> is_matrix: mx does not have 2 rows.
#> [1] FALSE
is_matrix(as.table(matrix(1:4, nrow = 2, ncol = 2)))
#> [1] TRUE
