Skip to contents

Verify and correct the input \(I\) by \(J\) contingency table to ensure it is properly formatted as a data matrix with row (adverse event) and column (drug) names.

Usage

check_and_fix_contin_table(contin_table)

Arguments

contin_table

A data matrix or a data frame of an \(I\) by \(J\) contingency table with or without prespecified row and column names.

Value

A data matrix of an \(I\) by \(J\) contingency table with row and column names.

Examples

# Create a 6 by 4 data matrix
set.seed(42)
dat_mat <- matrix(rpois(6 * 4, 20), nrow = 6)
dat_mat
#>      [,1] [,2] [,3] [,4]
#> [1,]   26   19   25   18
#> [2,]   17   29   24   12
#> [3,]   20   19   23   27
#> [4,]   15   25   22   21
#> [5,]   19   30   24   21
#> [6,]   26   13   16   18

# Check the format of the data matrix and assign row and column names
contin_table <- check_and_fix_contin_table(dat_mat)
contin_table
#>      drug_1 drug_2 drug_3 drug_4
#> AE_1     26     19     25     18
#> AE_2     17     29     24     12
#> AE_3     20     19     23     27
#> AE_4     15     25     22     21
#> AE_5     19     30     24     21
#> AE_6     26     13     16     18