Learn R Programming

sjstats (version 0.7.1)

phi: Measures of associations for contingency tables

Description

Compute measures of associtations for a contingency table, like Phi coefficient or Cramer's V.

Usage

phi(tab)
cramer(tab)

Arguments

tab
A table or ftable. Tables of class xtabs and other will be coerced to ftable objects.

Value

  • For phi(), the table's Phi value.
  • For cramer(), the table's Cramer's V.

Examples

Run this code
# Phi coefficient for 2x2 tables
tab <- table(sample(1:2, 30, TRUE), sample(1:2, 30, TRUE))
phi(tab)

# Cramer's V for nominal variables with more than 2 categories
tab <- table(sample(1:2, 30, TRUE), sample(1:3, 30, TRUE))
cramer(tab)

Run the code above in your browser using DataLab