This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(gt) | |
| library(htmltools) | |
| # ── Helper function: wrap a gt table with clickable footnote → column highlighting ── | |
| gt_interactive_footnotes <- function(gt_tbl, highlight_color = "#fff3cd", duration_ms = 2500) { | |
| tagList( | |
| tags$style(HTML(sprintf(" | |
| .gt_table .gt-highlight-col { | |
| background-color: %s !important; | |
| transition: background-color 0.3s ease; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(gt) | |
| library(htmltools) | |
| df <- data.frame( | |
| variable = c("age", "income", "score"), | |
| mean = c(35.2, 52000, 78.4), | |
| annotation = c( | |
| "Respondent age in years, collected via survey", | |
| "Annual household income in USD, self-reported", | |
| "Composite score from 3 Likert items (α = 0.87)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(gt) | |
| make_annotation <- function(id, text) { | |
| htmltools::HTML(glue::glue(' | |
| <span onclick=" | |
| var el = document.getElementById(\'ann-{id}\'); | |
| el.style.display = el.style.display === \'none\' ? \'block\' : \'none\'; | |
| " style="cursor:pointer; display:inline-flex; align-items:center; | |
| justify-content:center; width:22px; height:22px; border-radius:50%; | |
| background:#6c757d; color:white; font-size:12px; font-weight:bold;"> |