Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mosaicPlot

Mosaic Plot


Description

Plots (extended) mosaic displays via mosaic. The last response variable is highlighted. A high-dimensional contingency table is calculated via structable from the given dataset. Flat contingency table splits predictors horizontally and optional responses vertically.

Usage

mosaicPlot(
  dataset = cs.in.dataset(),
  preds = cs.in.predictors(),
  resps = cs.in.responses(),
  return.results = FALSE,
  ...
)

Arguments

dataset

[data.frame]
Dataset with named columns. The names correspond to predictors and responses.

preds

[character]
Character vector of predictor variables.

resps

[character]
Character vector of response variables.

return.results

[logical(1)]
If FALSE the function returns TRUE invisibly. If TRUE, it returns a list of results. Default is FALSE.

...

[ANY]
Additional arguments to be passed to mosaic . Please consider possible script variables (scriptvars) to prevent duplicates.

Value

Logical [TRUE] invisibly and outputs to Cornerstone or, if return.results = TRUE, list of resulting data.frame objects:

long.contingency

Contingency table in long format.

Examples

# Draw mosaic plot from 'titanic' data:
mosaicPlot(titanic, c("Class", "Age", "Sex", "Survived"))
res = mosaicPlot(titanic, c("Class", "Age"), c("Sex", "Survived"), return.results = TRUE)
print(res)

CornerstoneR

Collection of Scripts for Interface Between 'Cornerstone' and 'R'

v2.0.2
GPL-3
Authors
Gerrith Djaja [aut, cre], Dirk Surmann [aut] (<https://orcid.org/0000-0003-0873-137X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.