View source: R/ggassoc_crosstab.R
ggassoc_crosstab | R Documentation |
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.
ggassoc_crosstab(data, mapping, max.phi=.8, sort="none", axes.labs=TRUE, ticks.labs=TRUE, text.size=3)
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. |
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.
a ggplot object
Nicolas Robette
assoc.twocat
, phi.table
, catdesc
,
assoc.yx
, darma
, ggassoc_phiplot
, ggpairs
data(Taste) ggassoc_crosstab(data=Taste, mapping=ggplot2::aes(x=Age, y=Classical))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.