CRAN status lifecycle R-CMD-check


Vega-Lite is an implementation of the grammar-of-graphics, rendered in the browser with interactivity.

The goal of vegawidget is to render Vega-Lite and Vega specifications as htmlwidgets, and to provide you a means to communicate with a Vega chart using JavaScript or Shiny. Its ambition is to be a low-level interface to the Vega(-Lite) API, such that other packages can build upon it to offer higher-level functions to compose Vega(-Lite) specifications.

Accordingly, this package may be useful to:


New to vegawidget 0.3.2


You can install vegawidget from CRAN with:


The development version of vegawidget is available from GitHub with:

# install.packages("devtools")

Note: There are documentation websites for both the CRAN version and the development version of this package.


Vega(-Lite) specifications are just text, formatted as JSON. However, in R, we can use lists to build specifications:


spec_mtcars <-
    `$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")
  ) %>% 

The 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:

For more, please see our Getting Started article. Additionally, the Vega-Lite website has a comprehensive introduction.

Other articles for this package:



Contributions are welcome, please see this guide. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.