Learn R Programming

DanielBiostatistics10th (version 0.2.6)

binTab: Boolean Test-&-Disease or Risk-&-Disease Table

Description

To create a Boolean test-&-disease or risk-&-disease table.

Usage

binTab(x, ...)

# S3 method for matrix binTab(x, ...)

# S3 method for table binTab(x, ...)

# S3 method for formula binTab(formula, data, ...)

Value

Function binTab returns a two-by-two integer

matrix.

Arguments

x

(an R object convertible to a) \(2\times 2\) integer matrix, contingency table of two Boolean variables. The endpoint (i.e., disease) is on rows and the test/risk on columns.

formula

formula in the fashion of ~disease+test or ~disease+risk, see function xtabs

data

a data.frame

Details

Function binTab creates a \(2\times 2\) test-&-disease contingency table with layout

Test (\(-\))Test (\(+\))
Disease (\(-\))\(x_{--}\)\(x_{-+}\)
Disease (\(+\))\(x_{+-}\)\(x_{++}\)

or a \(2\times 2\) risk-&-disease contingency table with layout

Risk Factor (\(-\))Risk Factor (\(+\))
Disease (\(-\))\(x_{--}\)\(x_{-+}\)
Disease (\(+\))\(x_{+-}\)\(x_{++}\)

The endpoint (i.e., disease) must be on the rows and the test/risk on the columns.

See Also

Function caret::confusionMatrix does not provide confidence intervals of sensitivity, specificity, etc.

Examples

Run this code
binTab(matrix(c(7L, 3L, 8L, 6L), nrow = 2L))
binTab(matrix(c(7L, 3L, 8L, 6L), nrow = 2L, dimnames = list(X = c('a','b'), NULL)))
binTab(~ (mag < 4.5) + (depth > 400), data = quakes)

Run the code above in your browser using DataLab