Learn R Programming

sjPlot (version 2.0.0)

sjp.chi2: Plot Pearson's Chi2-Test of multiple contingency tables

Description

Plot p-values of Pearson's Chi2-tests for multiple contingency tables as ellipses or tiles. Requires a data frame with dichotomous (dummy) variables. Calculation of Chi2-matrix taken from https://talesofr.wordpress.com/2013/05/05/ridiculously-photogenic-factors-heatmap-with-p-values/{Tales of R}.

Usage

sjp.chi2(df, title = "Pearson's Chi2-Test of Independence",
  axis.labels = NULL, wrap.title = 50, wrap.labels = 20,
  show.legend = FALSE, legend.title = NULL, prnt.plot = TRUE)

Arguments

Value

(Insisibily) returns the ggplot-object with the complete plot (plot) as well as the data frame that was used for setting up the ggplot-object (mydf).

See Also

http://talesofr.wordpress.com/2013/05/05/ridiculously-photogenic-factors-heatmap-with-p-values/{Tales of R}.

Examples

Run this code
# create data frame with 5 dichotomous (dummy) variables
mydf <- data.frame(as.factor(sample(1:2, 100, replace=TRUE)),
                   as.factor(sample(1:2, 100, replace=TRUE)),
                   as.factor(sample(1:2, 100, replace=TRUE)),
                   as.factor(sample(1:2, 100, replace=TRUE)),
                   as.factor(sample(1:2, 100, replace=TRUE)))
# create variable labels
items <- list(c("Item 1", "Item 2", "Item 3", "Item 4", "Item 5"))

# plot Chi2-contingency-table
sjp.chi2(mydf, axis.labels = items)

Run the code above in your browser using DataLab