crossTable: contingency table of 2 variables

Description Usage Arguments Value Author(s) See Also Examples

View source: R/crosstable.R

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

1
 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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 June 7, 2021, 5:06 p.m.