Open jpcompartir opened 9 months ago
A very basic implementation would look like this
` library(ggmosaic) library(ggplot2) mosaic_plot <- function(data, x_var, y_var){
x_sym <- rlang::ensym(x_var) y_sym <- rlang::ensym(y_var)
plot <- data %>% ggplot2::ggplot() + ggmosaic::geom_mosaic(aes(x = ggmosaic::product(!!x_sym), fill = !!y_sym)) + dr_theme_capture() + theme(panel.grid = element_blank())
return(plot) }`
For displaying x in y and y in x Useful for two categorical variables Functionality for adding raw values + % to bars of a certain size/value Guidance for highlighting specific values of x or y
Probably using ggmosaic but if other more suitable add-ons (and best if no added deps!) then no probs