crosstabplot {eeptools} | R Documentation |
Draw a visual crosstab (mosaic plot) with shading for correlations and labels in each cell.
Description
Improves labeling of mosaic plots over mosaic
from the vcd package
Usage
crosstabplot(
data,
rowvar,
colvar,
varnames,
title = NULL,
subtitle = NULL,
label = FALSE,
shade = TRUE,
...
)
Arguments
data |
a data object, matrix or dataframe, that contains the categorical variables to compose the crosstab |
rowvar |
a character value for the column in data that will be displayed on the rows of the crosstab |
colvar |
a character value for the column in data that will be displayed in columns of the crosstab |
varnames |
a character vector of length two with the labels for rowvar and colvar respectively |
title |
a character vector of length one that contains the main title for the plot |
subtitle |
a character vector of length one that contains the subtitle displayed beneath the plot |
label |
logical, if TRUE cells will be labeled, else they will not |
shade |
logical, if TRUE cells will be shaded with Pearson residuals |
... |
additional arguments to |
Value
A mosaic plot
See Also
mosaic
which this function wraps
crosstabs
which does the data manipulation for the crosstab
Examples
df <- data.frame(cbind(x=seq(1,3,by=1), y=sample(LETTERS[6:8],60,replace=TRUE)),
fac=sample(LETTERS[1:4], 60, replace=TRUE))
varnames<-c('Quality','Grade')
myCT <- crosstabs(df, rowvar = "x",colvar = "fac", varnames = varnames, digits =2)
crosstabplot(df, rowvar = "x",colvar = "fac", varnames = varnames,
title = 'My Plot', subtitle = 'Foo', label = FALSE, shade = TRUE, digits = 3)