Learn R Programming

HDLSSkST (version 2.1.0)

rctab: Generates an \(r\times c\) Contingency Table

Description

A function that generates an \(r\times c\) contingency table with the same marginal totals as given \(r\times c\) contingency table.

Usage

rctab(M)

Arguments

M

\(r\times c\) contingency table

Value

generated \(r\times c\) contingency table

References

Cyrus R Mehta and Nitin R Patel (1983). A network algorithm for performing Fisher's exact test in rxc contingency tables, Journal of the American Statistical Association, 78(382):427-434, doi:10.2307/2288652.

Examples

Run this code
# NOT RUN {
# Generation of rxc Contingency Table:
   set.seed(151)
   mat <- matrix(1:20,5,4, byrow = TRUE)
   rctab(mat)

   ## outputs:
   #      [,1] [,2] [,3] [,4]
   #[1,]    3    4    0    3
   #[2,]    4    5   10    7
   #[3,]    8    7   12   15
   #[4,]   18   16   13   11
   #[5,]   12   18   20   24
   
# }

Run the code above in your browser using DataLab