knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
dtsmartr supports exporting your interactive grid sessions as offline-capable standalone HTML files, as well as embedding them seamlessly inside R Markdown (.Rmd) and Quarto (.qmd) dynamic reports.
save_dtsmartr)Export any data frame as a standalone web app using the save_dtsmartr() function:
library(dtsmartr) # Export as a self-contained portable HTML file save_dtsmartr( data = mtcars, file = "reports/mtcars_dashboard.html" )
The resulting file runs offline in any browser without needing R, Shiny, or a network connection.
selfcontained = TRUE (Default): Combines all React code, styling assets, and data base64 streams directly into a single .html file. Requires Pandoc to compile.selfcontained = FALSE: Recommended for large datasets or environments without Pandoc. It saves a lightweight .html file alongside a <file>_files/ companion directory containing the shared javascript and style sheets.You can render dtsmartr interactive grids inline in any R Markdown HTML document.
Simply place the function inside standard code chunks. Set R Markdown chunk options (like echo = FALSE or message = FALSE) to suppress code display and warnings:
--- title: "Clinical Analysis Report" output: html_document --- Below is the interactive labs analysis grid: ```r library(dtsmartr) dtsmartr(mtcars) ```
When you knit the document, R Markdown compiles the widget as an interactive grid directly inline with your text.
Quarto supports dtsmartr natively out of the box. Add the code chunk using Quarto's standard syntax and comments:
--- title: "Study Cohort Review" format: html --- ## Laboratory Panel Exploration Explore the interactive subject database: ```r #| echo: false #| message: false #| warning: false library(dtsmartr) dtsmartr(mtcars) ```
When Quarto renders to HTML (quarto render report.qmd), the widget embeds inside the page container.
To see what standalone HTML reports generated by save_dtsmartr() look and behave like offline, you can download these pre-compiled samples:
Simply download, unzip (for the large report), open the .html file locally in any modern web browser, and test all scrolling, column anchoring, and reordering features offline!
Here is an actual live rendering of dtsmartr embedded inside the R Markdown page container of this article, showing how it looks inside your generated reports:
library(dtsmartr) dtsmartr(mtcars)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.