powered by
ggmosaic for mosaic plot
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 )
a ggplot
your dataframe, must have 3 columns, the third column must be numeric
parameters parse to geom_rect
geom_rect
rect_space, defalut 0.
show "number" or "percentage" or "none"
parameters parse to geom_text
geom_text
show x label on "top" or "bottom" or "none"
show y label on "right" or "left" or "none"
whether show chisq test
data(mtcars) tab <- dplyr::count(mtcars, gear, cyl) ggmosaic(tab, show_number = "number", x_label = "top", y_label = "right", chisq_test = TRUE )
Run the code above in your browser using DataLab