vw_set_base_url: Set base URL

View source: R/set-base-url.R

vw_set_base_urlR Documentation

Set base URL

Description

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.

Usage

vw_set_base_url(url)

Arguments

url

character URL to use as the base URL.

Value

character called for side effects, it returns the previous value invisibly.

Examples

 # 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)

vegawidget documentation built on May 29, 2024, 12:17 p.m.