# 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)
Run the code above in your browser using DataLab