This is the key difference with the vegalite package: it provides a set of higher-level functions to compose specifications, whereas vegawidget concerns itself mainly with the rendering of the htmlwidget.
To be clear, although Vega-Lite offers a grammar-of-graphics, this package does not offer a user-friendly framework to compose graphics, like those provided by ggplot2 or ggvis. However, this package may be useful to:
You can install vegawidget from CRAN with:
You can also install vegawidget from GitHub with:
This package supports these versions of Vega libraries:
library("vegawidget")vega_version()#> $vega_lite#>  "2.6.0"#>#> $vega#>  "4.0.0"#>#> $vega_embed#>  "3.25.0"
In practical terms, this means that this version of vegawidget will be the only version that will display properly using version 1.1.x of the RStudio IDE.
As soon as Vega-Lite makes its 3.0.0 release, we will make another vegawidget release - for which you will need to use a (presently preview) version of the RStudio IDE at least 1.2.x.
Vega(-Lite) specifications are just text, formatted as JSON. However, in R, we can use lists to build specifications:
spec_mtcars <-list(`$schema` = vega_schema(), # specifies Vega-Litedescription = "An mtcars example.",data = list(values = mtcars),mark = "point",encoding = list(x = list(field = "wt", type = "quantitative"),y = list(field = "mpg", type = "quantitative"),color = list(field = "cyl", type = "nominal"))) %>%as_vegaspec()
as_vegaspec() function is used to turn the list into a vegaspec;
many of this package’s functions are built to support, and render,
The appearance of the chart above depends on where you are reading it:
On this package’s pkgdown site, it is rendered as part of an HTML environment, showing its full capabilities.
At its GitHub code site, the chart is further rendered as a static PNG.
This is package a low-level interface to Vega-Lite and the Vega ecosystem, which has a lot of powerful capabilities, highlighted in this series of articles:
Although there is an article dedicated to this aspect of the package, it warrants further emphasis.
This package provides functions to render Vega(-Lite) specifications; although it provides some helpers, it does not provide higher-level functions to build specifications. Rather, this is left to other packages. Even though you can use its functions directly, you are invited to import and re-export them for use in your package.
Accordingly, this package offers a templating function,
use_vegawidget(), to help you integrate vegawidget functions into your
package. For example, it is used to import and re-export vegawidget
functions for the altair package.
The two biggest known limitations are both associated with vegaspecs that contain datasets specified using remote URLs:
The RStudio IDE does not let you access remote URLs for security reasons. A chart that accesses remote data will not render in the IDE; it will render in a browser window.
The image functions use nodejs to create SVG strings. We are not able to configure the proxy in our node scripts, so if your computer uses a proxy to access remote data, our functions will not create the images properly.
vw_write_png()- these functions require that you have node installed on your computer, and the rsvg package, to use
elementId argument to
vegawidget(); had been available as part of
... passed to
compiles Shiny demonstration apps in
inst/shiny-demo, adds function
vw_shiny_demo() to access them
adds Shiny setter-functions:
vw_shiny_get_event(), and handler helper-functions
tries a kinder, gentler method for enforcing sizing by implementing a sizing policy rather than overwriting the enclosing element
vw_retrieve_block(); moved to vegablock
adds learnr tutorial, "Overview"
changes default-display for
vw_rename_data() to reanme named datasets within a vegaspec (#34)
vw_serialize_data() to help format dates and datetimes in data frames (#33)
vega_schema() to create a string describing a schema-URL (#32)
use_vegawidget() to help other packages use these functions (#21)
overhauls the API (#15, with @AliciaSchep)
NEWS.mdfile to track changes to the package