Convenience wrapper around htmlwidgets::saveWidget
save_widget(
widget,
path,
title = class(widget)[[1]],
type = "direct",
...,
libdir = NULL,
libpath = "relative"
)
htmlwidget
Where to save HTML file
Title of HTML page
One of "direct"
, "lib"
, or "intermediate"
Directory for HTML dependencies (if type
is "lib"
)
Specify "relative"
or "absolute"
HTML dependency paths
(if type
is "lib"
)
There are three ways to save an htmlwidget. If type
is "direct"
,
a self-contained HTML file is saved as usual. save_widget
helps in this case
due to an apparent bug in saveWidget
if attempting to save to a directory
other than the current working directory.
If type
is "lib"
, a non-self-contained HTML file is created. In this
case, "libdir"
may be provided. Also, "libpath"
may be provided as either
"relative"
(default) or "absolute"
, which specifies whether paths
in the html file to the library files are relative or absolute. In contrast to
previous function save_leaflet
, "libdir"
does not necessarily need
to be a child of the directory containing path
.
If type
is "intermediate"
, a self-contained HTML file is generated, but
through an intermediate step of first creating a non-self-contained HTML file, then
producing the self-contained file from this by writing a new HTML after copying the
HTML dependencies into the HTML file. This can be useful when saving large htmlwidgets,
as the attempt to save as a self-contained file using saveWidget
will
fail on a pandoc memory error. This approach enables the saving of larger
widgets as self-contained HTML files.