data_frame_from_2x2: create a data frame from a 2x2 matrix

View source: R/data_frame_from_2x2.R

data_frame_from_2x2R Documentation

create a data frame from a 2x2 matrix

Description

create a data frame from a 2x2 matrix

Usage

data_frame_from_2x2(x)

Arguments

x

a 2x2 matrix or 3D array with exposure variable in rows and outcome in columns

Value

a data frame with the important combinations:

  • A_exp_cases

  • B_exp_controls

  • C_unexp_cases

  • D_unexp_controls

  • total_cases (A + B)

  • total_controls (C + D)

  • total_exposed (A + C)

  • total_unexposed (B + D)

  • total (A + B + C + D)

Examples

arr <- c(10, 35, 90, 465, 36, 25, 164, 175)
arr <- array(arr,
  dim = c(2, 2, 2),
  dimnames = list(
    risk = c(TRUE, FALSE),
    outcome = c(TRUE, FALSE),
    old = c(FALSE, TRUE)
  )
)
arr
data_frame_from_2x2(arr)

R4EPI/tuni documentation built on March 20, 2023, 4:37 p.m.