knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

twoxtwo

build status (main) build status (dev)

The twoxtwo package provides a collection of functions to display, summarize, and analyze data in two-by-two contingency tables. Statistical analysis functions are oriented towards epidemiological investigation of exposure/outcome relationships.

Installation

To install the stable release from CRAN:

install.packages("twoxtwo")

Or to install the development release from GitHub:

## install.packages("devtools")
devtools::install_github("vpnagraj/twoxtwo", build_vignettes = TRUE)

Features

Usage

Example

First load twoxtwo and dplyr to help prep data:

library(twoxtwo)
library(dplyr)

Next create a object with S3 class twoxtwo. For this example, use the twoxtwo::titanic dataset. Note that "exposure" and "outcome" variables must each be binary variables:

crew_2x2 <-
  titanic %>%
  twoxtwo(.data = ., exposure = Crew, outcome = Survived)

crew_2x2

The twoxtwo class has its own summary.twoxtwo() method that computes effect measures (odds ratio, risk ratio, and risk difference):

summary(crew_2x2)

Individual measures of effect, hypothesis tests, and impact numbers can be calculated using the twoxtwo object. For example:

crew_2x2 %>%
  odds_ratio()
crew_2x2 %>%
  chisq()

Note that data analysis can also be performed without first creating the twoxtwo object:

titanic %>%
  odds_ratio(.data = ., exposure = Crew, outcome = Survived)
titanic %>%
  chisq(.data = ., exposure = Crew, outcome = Survived)

Vignettes

The package includes vignettes to describe usage in more detail.

For details on the twoxtwo data structure and demonstration of basic usage:

vignette("basic-usage", package = "twoxtwo")

For formulas and examples of how to calculate measures of effect:

vignette("measures-of-effect", package = "twoxtwo")

For information on hypothesis testing functionality in the package:

vignette("hypothesis-testing", package = "twoxtwo")

For formulas and demonstration of attributable fraction and impact number calculations:

vignette("af-impact", package = "twoxtwo")

Contributing

Please use GitHub issues to report bugs or request features. Contributions will be reviewed via pull requests.



vpnagraj/twoxtwo documentation built on Nov. 3, 2021, 6:20 p.m.