vegawidget (version 0.1.0)

knit_print.vegaspec: Knit-print method

Description

Currently, the only supported options are vega.width, vega.height (as pixels) and vega.embed (as a list).

Usage

knit_print.vegaspec(spec, ..., options = NULL)

Arguments

spec

object to be coerced to vegaspec, a Vega/Vega-Lite specification

...

other arguments

options

list, knitr options

Details

When knitting to an HTML-based format, the spec is rendered as normal.

When knitting to an non-html format, if the webshot package and PhantomJS are installed, an image will be generated instead. You may find webshot::install_phantomjs() to be useful.

This function has potential to be developed further; it calls vegawidget() using the options vega.width, vega.height and vega.embed:

  • vega.width and vega.height are passed to vegawidget() as width and height, respectively. These are coerced to numeric, so it is ineffective to specify a percentage.

  • vega.embed is passed to vegawidget() as embed. The function vega_embed() can be useful to set vega.embed.

See Also

webshot::install_phantomjs(), vw_autosize(), vega_embed()