vw_set_base_url | R Documentation |
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.
vw_set_base_url(url)
url |
|
character
called for side effects, it returns the previous value
invisibly.
# this is the URL used for Vega datasets
previous <- vw_set_base_url("https://cdn.jsdelivr.net/npm/vega-datasets@2")
# reset to previous value
vw_set_base_url(previous)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.