Draw a visual crosstab (mosaid plot) with shading for correlations and labels in each cell.

Share:

Description

Improves labeling of mosaic plots over mosaic from the vcd package

Usage

1
2
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 vlue 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 crosstabs e.g. digits

Value

A mosaic plot

Source

http://www.rexdouglass.com/blog:3

See Also

mosaic which this function wraps crosstabs which does the data manipulation for the crosstab

Examples

1
2
3
4
5
6
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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.