Share an R Markdown report
R Markdown solved reproducibility and stopped there. rmarkdown::render()
gives you a self-contained HTML file with every plot inlined and every
widget working — and then the distribution story is "email it," because
that's what's available. So the analysis becomes a 12 MB attachment, the
feedback comes back as "the chart on page 4 looks off," and the next
month's rerun starts a second attachment with no relationship to the first.
Publish from R
rmarkdown::render("report.Rmd", output_file = "report.html")
httr::PATCH(
paste0("https://commareports.com/api/v1/reports/", Sys.getenv("COMMA_REPORT_ID")),
httr::add_headers(Authorization = paste("Bearer", Sys.getenv("COMMA_API_TOKEN"))),
body = list(
title = paste("Monthly analysis —", format(Sys.Date(), "%Y-%m")),
html = readr::read_file("report.html")
),
encode = "json"
)
PATCH on a saved report id rather than POST keeps one URL with a
revision per render — the link you sent in March still opens August's
numbers, and any two months can be
diffed. Use a scoped token with
reports:write and keep it in .Renviron, not in the .Rmd.