View source: R/save_dtsmartr.R
| save_dtsmartr | R Documentation |
Exports any data.frame as a fully interactive, standalone HTML file powered
by the dtsmartr widget. The resulting file can be opened in any modern web
browser without an active R session or internet connection, making it ideal
for offline use and sharing with collaborators.
save_dtsmartr(
data,
file,
selfcontained = TRUE,
title = "dtsmartr",
open = FALSE,
background = "white",
libdir = NULL,
width = NULL,
height = NULL,
elementId = NULL,
options = dtsmartr_options(),
verbose = TRUE
)
data |
A |
file |
Character string. Path to the output HTML file. The |
selfcontained |
Logical. When |
title |
Character string. Browser tab / window title for the saved HTML
page. Defaults to |
open |
Logical. When |
background |
Character string. CSS colour for the page background.
Defaults to |
libdir |
Character string or |
width |
Numeric or |
height |
Numeric or |
elementId |
Character string or |
options |
Named list of UI options generated by |
verbose |
Logical. When |
selfcontained | Output | Best for |
TRUE (default) | Single .html file | Email / sharing |
FALSE | .html + _files/ folder | Local use / large datasets |
Self-contained files embed the React runtime and widget code (~120 KB
gzipped) along with the data. For very large datasets (> 100 k rows) or
when generating many files, prefer selfcontained = FALSE.
The generated HTML works in all modern browsers (Chrome, Firefox, Edge, Safari 14+). No internet connection is required.
The absolute path to the saved HTML file, invisibly.
dtsmartr() for creating the widget object interactively,
htmlwidgets::saveWidget() for the underlying save mechanism.
# == Basic usage =============================================================
# Save mtcars as a self-contained HTML (single portable file)
tmp_file <- tempfile(fileext = ".html")
save_dtsmartr(mtcars, tmp_file)
# Open in the browser right after saving
tmp_file_open <- tempfile(fileext = ".html")
save_dtsmartr(mtcars, tmp_file_open, open = TRUE)
# == Custom options ==========================================================
tmp_file_opts <- tempfile(fileext = ".html")
save_dtsmartr(
mtcars,
tmp_file_opts,
options = dtsmartr_options(hidden_columns = "cyl", advanced_filter = FALSE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.