You can use this function to retrieve a vegaspec from blocks (gists) where the spec is in its own JSON file.

vw_retrieve_block(id, file = NULL, endpoint = NULL, env_pat = NULL,
  quiet = FALSE)

Arguments

id

character block id

file

character filename within block, NULL will retrieve first JSON file

endpoint

character, base endpoint for GitHub API, defaults to "https://api.github.com"; useful to specify with GitHub Enterprise, e.g. "https://github.acme.com/api/v3" (not yet implemented)

env_pat

character, name of environment variable that contains a GitHub PAT (Personal Access Token), defaults to "GITHUB_PAT"; Useful to specify with GitHub Enterprise, e.g. "GITHUB_ACME_PAT" (not yet implemented)

quiet

logical, indicates to supress messages

Value

S3 object of class vegaspec

Details

You will need a GitHub Personal Access Token stored in an environment variable called GITHUB_PAT. See Happy Git with R for more information on how to acquire and store a PAT.

The file argument accepts a regular expression for the name of the JSON file within the gist. If you don't provide a file, it will return the first file in the gist with a .json extension (not case sensitive). Don't worry about escaping the dots in file, it will likely not make a difference.

See also

Examples

# NOT RUN {
  # https://bl.ocks.org/domoritz/455e1c7872c4b38a58b90df0c3d7b1b9
  spec_bars <-
    vw_retrieve_block("455e1c7872c4b38a58b90df0c3d7b1b9")
  spec_bars <-
    vw_retrieve_block("dmoritz/455e1c7872c4b38a58b90df0c3d7b1b9")
  spec_bars <-
    vw_retrieve_block(
      "455e1c7872c4b38a58b90df0c3d7b1b9",
      file = "bar.vl.json"
    )
# }