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.

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)
#> $long.contingency #> Class Age Sex Survived Freq #> 1: 1st Adult Female No 4 #> 2: 2nd Adult Female No 13 #> 3: 3rd Adult Female No 89 #> 4: Crew Adult Female No 3 #> 5: 1st Child Female No 0 #> 6: 2nd Child Female No 0 #> 7: 3rd Child Female No 17 #> 8: Crew Child Female No 0 #> 9: 1st Adult Male No 118 #> 10: 2nd Adult Male No 154 #> 11: 3rd Adult Male No 387 #> 12: Crew Adult Male No 670 #> 13: 1st Child Male No 0 #> 14: 2nd Child Male No 0 #> 15: 3rd Child Male No 35 #> 16: Crew Child Male No 0 #> 17: 1st Adult Female Yes 140 #> 18: 2nd Adult Female Yes 80 #> 19: 3rd Adult Female Yes 76 #> 20: Crew Adult Female Yes 20 #> 21: 1st Child Female Yes 1 #> 22: 2nd Child Female Yes 13 #> 23: 3rd Child Female Yes 14 #> 24: Crew Child Female Yes 0 #> 25: 1st Adult Male Yes 57 #> 26: 2nd Adult Male Yes 14 #> 27: 3rd Adult Male Yes 75 #> 28: Crew Adult Male Yes 192 #> 29: 1st Child Male Yes 5 #> 30: 2nd Child Male Yes 11 #> 31: 3rd Child Male Yes 13 #> 32: Crew Child Male Yes 0 #> Class Age Sex Survived Freq #>