View source: R/crowd_plots_as_tabset.R
| crowd_plots_as_tabset | R Documentation |
Creates a Quarto tabset from a named list of ggplot2 objects, typically
generated by makeme() with crowd parameter. Each plot becomes a tab
with automatic height calculation and optional download links.
crowd_plots_as_tabset(
plot_list,
plot_type = c("cat_plot_html", "int_plot_html", "auto"),
save = FALSE,
fig_height = NULL,
fig_height_int_default = 6
)
plot_list |
A named list of ggplot2 objects. Names become tab labels.
Typically created with |
plot_type |
Character. Type of plots in the list. One of:
|
save |
Logical. If |
fig_height |
Numeric or NULL. Manual figure height override in inches.
If |
fig_height_int_default |
Numeric. Default height for interval plots when auto-calculation is not available (default: 6 inches). |
This function is designed to be called within a Quarto document code chunk.
It generates markdown that creates a tabset where each non-NULL plot in
plot_list appears as a separate tab.
Height Calculation:
For "cat_plot_html": Uses fig_height_h_barchart2() which accounts for
number of variables, categories, and label lengths
For "int_plot_html": Uses fig_height_int_default (simpler plots need
less sophisticated calculation)
For "auto": Detects type by checking for .category column (categorical)
vs numeric statistics columns (interval)
Requirements:
Must be run within knitr/Quarto context
Plots should be created with makeme()
Plot list should have meaningful names for tab labels
Invisibly returns NULL. The function's purpose is its side effect
of printing Quarto markdown that creates a tabset.
makeme() for creating plots with crowd parameter
fig_height_h_barchart2() for categorical plot height calculation
get_fig_title_suffix_from_ggplot() for caption generation
girafe() for interactive plot rendering
## Not run:
# In a Quarto document
plots <- makeme(
data = ex_survey,
dep = b_1:b_3,
crowd = c("target", "others"),
mesos_var = "f_uni",
mesos_group = "Uni of A"
)
# Create tabset with auto-detection
crowd_plots_as_tabset(plots)
# Create tabset for interval plots
int_plots <- makeme(
data = ex_survey,
dep = c_1:c_2,
indep = x1_sex,
type = "int_plot_html",
crowd = c("target", "others"),
mesos_var = "f_uni",
mesos_group = "Uni of A"
)
crowd_plots_as_tabset(int_plots, plot_type = "int_plot_html")
# Without download links
crowd_plots_as_tabset(plots, save = FALSE)
# With manual height override
crowd_plots_as_tabset(plots, fig_height = 8)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.