use_vegawidget: Add vegawidget functions to your package

View source: R/use-vegawidget.R

use_vegawidgetR Documentation

Add vegawidget functions to your package

Description

These functions are offered to help you import and re-export vegawidget functions in your package. For more detail, please see this article.

Usage

use_vegawidget(s3_class_name = NULL)

use_vegawidget_interactive()

Arguments

s3_class_name

character, name of an S3 class for object to be coerced to a vegaspec; default (NULL) implies no additional class

Details

use_vegawidget():

Adds vegawidget functions:

  • as_vegaspec(), vw_as_json()

  • format(), print(), knit_print()

  • vegawidget(), vega_embed(), vw_set_base_url()

  • vw_to_svg() and other image functions

  • vegawidgetOutput(), renderVegawidget()

In practical terms:

  • adds vegawidget to Imports in your package's DESCRIPTION file.

  • adds V8, withr, fs, rsvg, and png to Suggests in your package's DESCRIPTION file.

  • creates R/utils-vegawidget.R

  • you can delete references to functions you do not want to re-export.

If you have your own S3 class for a spec, specify the s3_class_name argument. You will have to edit ⁠R/utils-vegawidget-<s3_class_name>.R⁠:

  • add the code within your class's method for to coerce your object to a vegaspec.

To permit knit-printing of your custom class, you will have to add some code to your package's .onLoad() function.

use_vegawidget_interactive():

If you want to add the JavaScript and Shiny functions, use this after running use_vegawidget(). It adds:

  • vw_add_data_listener() and other listener-functions.

  • vw_handler_data() and other handler functions.

  • vw_shiny_get_data() and other Shiny getters.

  • vw_shiny_set_data() and other Shiny setters.

In practical terms:

  • adds shiny, dplyr, to Suggests.

  • creates R/utils-vegawidget-interactive.R.

  • at your discretion, delete references to functions you do not want to re-export.

Value

invisible NULL, called for side effects


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