# NOT RUN {
# call any of these functions using either a vegaspec or a vegawidget
svg <- vw_to_svg(vegawidget(spec_mtcars))
bmp <- vw_to_bitmap(spec_mtcars)
vw_write_png(spec_mtcars, file.path(tempdir(), "temp.png"))
vw_write_svg(spec_mtcars, file.path(tempdir(), "temp.svg"))
# To specify the path to a local file, use base_url
spec_precip <-
list(
`$schema` = vega_schema(),
data = list(url = "seattle-weather.csv"),
mark = "tick",
encoding = list(
x = list(field = "precipitation", type = "quantitative")
)
) %>%
as_vegaspec()
data_dir <- system.file("example-data/", package = "vegawidget")
vw_write_png(
spec_precip,
file.path(tempdir(), "temp-local.png"),
base_url = data_dir
)
# }
Run the code above in your browser using DataLab