ggmosaic | R Documentation |
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
)
tab |
your dataframe, must have 3 columns, the third column must be numeric |
rect_params |
parameters parse to |
rect_space |
rect_space, defalut 0. |
show_number |
show "number" or "percentage" or "none" |
number_params |
parameters parse to |
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 |
chisq_test |
whether show chisq test |
a ggplot
data(mtcars)
tab <- dplyr::count(mtcars, gear, cyl)
ggmosaic(tab,
show_number = "number", x_label = "top",
y_label = "right", chisq_test = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.