This function renders a specification with one of the native ggsql writers
and writes it to disk. The format is derived from the file extension:
.svg, .pdf, and .hep are written directly by the corresponding
writer, .png is converted from the SVG output using the rsvg package, and
.json writes the (deprecated) Vega-Lite representation.
Arguments
- spec
A
Specobject returned byggsql_execute().- file
Output file path. Extension determines format:
.svg,.pdf,.hep,.png, or.json.- width
Width in pixels.
- height
Height in pixels.
- dpi
Resolution in dots per inch.
Examples
reader <- duckdb_reader()
ggsql_register(reader, mtcars, "cars")
spec <- ggsql_execute(reader,
"SELECT * FROM cars VISUALISE mpg AS x, disp AS y DRAW point"
)
spec_file <- tempfile(fileext = ".svg")
ggsql_save(spec, spec_file)
