save_widget: Save htmlwidgets to an html file

View source: R/save_htmlwidget.R

save_widgetR Documentation

Save htmlwidgets to an html file

Description

Convenience wrapper around htmlwidgets::saveWidget

Usage

save_widget(
  widget,
  path,
  title = class(widget)[[1]],
  type = "direct",
  ...,
  libdir = NULL,
  libpath = "relative"
)

Arguments

widget

htmlwidget

path

Where to save HTML file

title

Title of HTML page

type

One of "direct", "lib", or "intermediate"

libdir

Directory for HTML dependencies (if type is "lib")

libpath

Specify "relative" or "absolute" HTML dependency paths (if type is "lib")

Details

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.


mvanhala/rutils documentation built on Feb. 13, 2023, 9:08 a.m.