Learn R Programming

GDAtools (version 1.7)

ggassoc_crosstab: Plots counts and associations of a crosstabulation

Description

For a cross-tabulation, plots the number of observations by using rectangles with proportional areas, and the phi measures of association between the categories with a diverging gradient of colour, using ggplot2.

Usage

ggassoc_crosstab(data, mapping, max.phi=.8, sort="none", 
axes.labs=TRUE, ticks.labs=TRUE, text.size=3)

Arguments

data

dataset to use for plot

mapping

aesthetic being used. It must specify x and y.

max.phi

numeric value, specifying the lower and upper limit of the scale for the color gradient filling the rectangles, i.e. for the phi measures of association. It corresponds to the maximum absolute value of phi one wants to represent in the plot.

sort

character. If "both", rows and columns are sorted according to the first factor of a correspondence analysis of the contingency table. If "x", only rows are sorted. If "y", only columns are sorted. If "none" (default), no sorting is done.

axes.labs

Whether to display the labels of the axes, i.e. the names of x and y. Default is TRUE.

ticks.labs

Whether to display the labels of the categories of x and y. Default is TRUE.

text.size

Size of the association measure. If NULL, the text is not added to the plot.

Value

a ggplot object

Details

The phi measure of association measures how much each combination of categories of x and y is over/under-represented.

Cramer's V measure of global association between x and y is displayed in upper-left corner of the plot.

This function can be used as a high-level plot with ggduo and ggpairs functions of the GGally package.

See Also

assoc.twocat, phi.table, catdesc, assoc.yx, darma, ggassoc_phiplot, ggpairs

Examples

Run this code
# NOT RUN {
data(Taste)
ggassoc_crosstab(data=Taste, mapping=ggplot2::aes(x=Age, y=Classical))
# }

Run the code above in your browser using DataLab