crossTable: contingency table of 2 variables

View source: R/crosstable.R

crossTableR Documentation

contingency table of 2 variables

Description

Creates a contingency table of 2 variables. Percentages are optionals by row, column or both. It can provides an optional statistic (Fisher or Chisquare).

Usage

 crossTable(data, var1, var2, percent="none", statistic="none")

Arguments

data

data.frame

var1

character - first varname - can be unquoted

var2

character - second varname - can be unquoted

percent

character - "none" (default) or ("row", "col", "both") - can be unquoted

statistic

character - "none" (default) or ("fisher", "chi2") - can be unquoted

Value

data.frame - contingency table

Author(s)

jean.pierre.decorps@gmail.com

See Also

orderFactors, CC, CS

Examples

library(EpiStats)

# Dataset by Anja Hauri, RKI.
data(Tiramisu)
DF <- Tiramisu

# Table with percentagges and statistic on ordered factors
DF %<>%
  orderFactors(ill , values = c(1,0), labels = c("YES", "NO")) %>%
  orderFactors(sex, values = c("males", "females"), labels = c("Males", "Females"))

crossTable(DF, "ill", "sex", "both", "chi2")


EpiStats documentation built on Oct. 25, 2023, 5:06 p.m.