Create a margot plot for visualising causal effects with flexible sorting, embed a compact interpretation, and return a transformed table.
Usage
margot_plot(
.data,
type = c("RD", "RR"),
order = c("alphabetical", "magnitude_desc", "magnitude_asc", "evaluebound_desc",
"evaluebound_asc", "custom", "default"),
custom_order = NULL,
title_binary = NULL,
include_coefficients = TRUE,
standardize_label = c("NZ", "US", "none"),
e_val_bound_threshold = 1.2,
adjust = c("none", "bonferroni", "holm"),
alpha = 0.05,
...,
options = list(),
label_mapping = NULL,
save_output = FALSE,
use_timestamp = FALSE,
base_filename = "margot_plot_output",
prefix = NULL,
save_path = here::here("push_mods"),
original_df = NULL,
bold_rows = FALSE,
rename_cols = FALSE,
col_renames = list(`E-Value` = "E_Value", `E-Value bound` = "E_Val_bound"),
rename_ate = FALSE
)
Arguments
- .data
data frame containing causal effect estimates with columns for effect sizes, confidence intervals, E-values and E-value bounds
- type
character. type of effect estimate: "RD" (risk difference) or "RR" (risk ratio). default "RD"
- order
character. sorting option for outcomes:
'alphabetical': sort by outcome name (A–Z)
'magnitude_desc': sort by absolute effect size, descending
'magnitude_asc': sort by absolute effect size, ascending
'evaluebound_desc': sort by E-value bound, descending
'evaluebound_asc': sort by E-value bound, ascending
'custom': user-defined order (requires custom_order)
'default': alias for 'magnitude_desc' (deprecated)
- custom_order
character vector. custom outcome ordering when order = 'custom'
- title_binary
character. deprecated parameter, kept for compatibility
- include_coefficients
logical. whether to add numeric labels to plot points
- standardize_label
character. label style: "NZ", "US", or "none"
- e_val_bound_threshold
numeric. threshold for reliable causal evidence
- adjust
character. multiplicity correction method: "none", "bonferroni", "holm"
- alpha
numeric. significance level for corrections
- ...
additional arguments passed to plot options
- options
list. plot styling options
- label_mapping
named character vector. outcome label mappings
- save_output
logical. whether to save results to file
- use_timestamp
logical. whether to add timestamp to saved filename
- base_filename
character. base name for saved file
- prefix
character. prefix for saved filename
- save_path
character. directory path for saved file
- original_df
data frame. original scale data for back-transformation
- bold_rows
logical. whether to bold rows exceeding E-value threshold
- rename_cols
logical. whether to rename E-value columns
- col_renames
named list. column name mappings for renaming
- rename_ate
logical. whether to rename effect column to "ATE"