These functions do the same thing: create a gist; they differ only in what they return. vw_create_block() returns a copy of spec so that it can be used in a pipe; vw_create_block_gistid() returns a list of information about the newly-created gist.

vw_create_block(spec, embed = vega_embed(), .block = vw_block_config(),
  version = vega_version(major = FALSE), description = NULL,
  readme = NULL, use_thumbnail = TRUE, use_preview = TRUE,
  git_method = c("https", "ssh"), endpoint = NULL, env_pat = NULL,
  block_host = NULL, quiet = FALSE, browse = TRUE)

vw_create_block_gistid(spec, embed = vega_embed(),
  .block = vw_block_config(), version = vega_version(major = FALSE),
  description = NULL, readme = NULL, use_thumbnail = TRUE,
  use_preview = TRUE, git_method = c("https", "ssh"),
  endpoint = NULL, env_pat = NULL, block_host = NULL,
  quiet = FALSE, browse = TRUE)

Arguments

spec

object to be coerced to vegaspec, a Vega/Vega-Lite specification

embed

list to specify vega-embed options, see vega_embed() for more details.

.block

character, YAML text for the .block file - use the helper function vw_block_config() to specify block-configuration

version

named list of character: names refer to JavaScript libraries vega, vega_lite, vega_embed, values are the tags for the versions to use in the block - use the helper function vega_version() with major = TRUE to use the current major versions rather than the versions supported in this package

description

character, description for the gist - if NULL, looks for a description field in spec.

readme

character, single line, path to a markdown file; multiple lines, markdown text

use_thumbnail

logical, indicates to include a thumbnail image

use_preview

logical, indicates to include a preview image

git_method

character, use "https" (default) or "ssh"

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)

block_host

character, hostname of blocks server, defaults to bl.ocks.org

quiet

logical, indicates to supress messages

browse

logical, indicates to open browser to blocks web-page when complete

Value

Called for side effects

create_block()

returns an invisible copy of spec

create_block_gistid()

returns a list with elements:

endpoint

character, git API endpiont

id

character, gist id

Details

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

If you are the default ("https") method to upload your gist, you will need to set another environment variable, GITHUB_USERNAME, according to your particular account.

The default versions of the Vega JavaScript libraries are this package's supported versions. To use the major (current) versions instead, use version = vega_version(major = TRUE).

If want to include preview and thumb images with the block, you will need nodejs installed on your system, and the processx and magick packages.

See also

Examples

# NOT RUN {
  # use supported versions
  vw_create_block(spec_mtcars)
  # use major versions
  vw_create_block(spec_mtcars, version = vega_version(major = TRUE))
  # return gist information
  vw_create_block_gistid(spec_mtcars)
# }