cat_compare | R Documentation |
cat_compare
gives details about the association between two categorical variables.
cat_compare(x, y, plot = TRUE)
x |
A categorical variable: the predictor or group variable, if appropriate |
y |
A categorical variable: the outcome, if appropriate |
plot |
Logical. Whether a mosaic plot should be drawn |
Strictly, x and y do not need to be factors but will be coerced into factors.
Returns a list including (1) two-way table of counts, (2) chi-squared test for independence, (3) Cramer's V standardized effect, and (4) ggplot2 column plot of proportions conditional on x, if requested.
The table of counts will include missing values of both variables, but these rows/columns are discarded prior to the chi-squared test and Cramer's V calculations.
v1 = rbinom(n=50, size=1, p=0.5)
v2 = rbinom(n=50, size=2, p=0.3 + 0.2*v1)
cat_compare(x=v1, y=v2, plot=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.