Vega-Lite is an implementation of the grammar-of-graphics, rendered in the browser with interactivity.
Accordingly, this package may be useful to:
This is a small release:
When converting vegaspec to JSON,
NA is serialized to
Update to a test to comply with changes to testthat.
vegawidget offers Vega-Lite 4.17.0 and Vega 5.17.0. Consequently, this package works only with browsers that support ES6. This includes all modern browsers and the RStudioIDE (version 1.2 and later).
You can install vegawidget from CRAN with:
The development version of vegawidget is available from GitHub with:
# install.packages("devtools") devtools::install_github("vegawidget/vegawidget")
Vega(-Lite) specifications are just text, formatted as JSON. However, in R, we can use lists to build specifications:
library("vegawidget") spec_mtcars <- list( `$schema` = vega_schema(), # specifies Vega-Lite description = "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, vegaspecs:
The rendering 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 to a static SVG file, then incorporated into the Markdown rendering.
Other articles for this package: