Learn R Programming

sjPlot (version 1.7)

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

Description

Plot Pearson's Chi2-Test of multiple contingency tables as ellipses or tiles. Requires a data frame with dichotomous (dummy) variables. Calculation of Chi2-matrix taken from http://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",
  axisLabels = NULL, breakTitleAt = 50, breakLabelsAt = 20,
  hideLegend = TRUE, legendTitle = NULL, printPlot = 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, axisLabels = items)

Run the code above in your browser using DataLab