ggmosaic: ggmosaic for mosaic plot

ggmosaicR Documentation

ggmosaic for mosaic plot

Description

ggmosaic for mosaic plot

Usage

ggmosaic(
  tab,
  rect_params = list(),
  rect_space = 0,
  show_number = c("number", "percentage", "none")[1],
  number_params = list(),
  x_label = c("top", "bottom", "none")[1],
  y_label = c("right", "left", "none")[1],
  label_params = list(),
  chisq_test = TRUE
)

Arguments

tab

your dataframe, must have 3 columns, the third column must be numeric

rect_params

parameters parse to geom_rect

rect_space

rect_space, defalut 0.

show_number

show "number" or "percentage" or "none"

number_params

parameters parse to geom_text

x_label

show x label on "top" or "bottom" or "none"

y_label

show y label on "right" or "left" or "none"

label_params

parameters parse to geom_text

chisq_test

whether show chisq test

Value

a ggplot

Examples

data(mtcars)
tab <- dplyr::count(mtcars, gear, cyl)
ggmosaic(tab,
  show_number = "number", x_label = "top",
  y_label = "right", chisq_test = TRUE
)

pcutils documentation built on June 26, 2024, 1:06 a.m.