Skip to content

Instantly share code, notes, and snippets.

View Alaburda's full-sized avatar

Paulius Alaburda Alaburda

View GitHub Profile
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;
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)"
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;">