cramer_v | R Documentation |
cramer_v()
computes Cramer's V for a two-way frequency table, measuring the strength of association between two categorical variables.
cramer_v(x)
x |
A contingency table (of class |
Cramer's V is based on the chi-squared statistic and adjusts for the size of the table. It is suitable for nominal (unordered categorical) variables.
A numeric vector of length 1, representing the Cramer's V statistic.
# Example with mtcars dataset
data(mtcars)
# Discretize continuous variables
mtcars$gear <- as.factor(mtcars$gear)
mtcars$cyl <- as.factor(mtcars$cyl)
# Create contingency table
tab <- table(mtcars$gear, mtcars$cyl)
# Compute Cramer's V
cramer_v(tab)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.