This is useful for specs where data is specified using a URL.
Using this function to set the base URL, you can specify the data URL
in specs using the relative path from the base.
For example, this
Vega-Lite example
uses the base URL https://cdn.jsdelivr.net/npm/vega-datasets@2
. In a spec,
instead of specifying:
data = "https://cdn.jsdelivr.net/npm/vega-datasets@2/data/cars.json"
You can call:
vw_set_base_url("https://cdn.jsdelivr.net/npm/vega-datasets@2")
Then specify:
data = "data/cars.json"
This function sets the value of getOption("vega-embed")$loader$baseURL
.
You need set it only once in a session or RMarkdown file.