R/getOR.R

Defines functions getOR

Documented in getOR

#' Calculate the odds ratio
#'
#' Calculate the odds ratio from a 2 by 2 table.
#'
#' @param x A two by two matrix.
#'
#' @return The odds ratio calculated from `x`.
#'
#' @export
#' @author Andrew E Jaffe
#'
#' @examples
#'
#' getOR(matrix(seq_len(4), ncol = 2))
getOR <- function(x) {
    stopifnot(nrow(x) == 2)
    stopifnot(ncol(x) == 2)
    x[1, 1] / x[2, 1] / x[1, 2] * x[2, 2]
}
LieberInstitute/jaffelab documentation built on April 1, 2024, 7:26 a.m.