R/NGLVieweR_example.R

Defines functions NGLVieweR_example

Documented in NGLVieweR_example

#'
#' Run NGLVieweR example Shiny app
#'
#' @description
#' Launch an example to demonstrate how to use \code{NGLvieweR} in Shiny.
#'
#' @param example Example type for which to see an example, possible values are:
#' "basic", "API", "addSelection", "removeSelection", "snapshot",
#' "updateAnimation", "updateColor", "updateFocus", "updateFullscreen",
#' "updateRepresentation", "updateSelection", "updateStage", "updateVisibility" and
#' "updateZoomMove".
#' @return Call to load Shiny example.
#' @examples
#'
#' if (interactive()) {
#'
#' # Basic example
#' NGLVieweR_example("basic")
#'
#' # Example with API calls
#' NGLVieweR_example("API")
#'
#' # Function specific example
#' NGLVieweR_example("addSelection")
#' }
#'
#'@importFrom shiny shinyAppDir
#'
#'@export
NGLVieweR_example <- function(example = "basic") {
example <- match.arg(
  arg = example,
  choices = c(
    "basic", "API", "addSelection", "removeSelection", "snapshot",
    "updateAnimation", "updateColor", "updateFocus", "updateFullscreen",
    "updateRepresentation", "updateSelection", "updateStage", "updateVisibility",
    "updateZoomMove"
  ),
  several.ok = FALSE
)
path <- file.path("examples", example)
shinyAppDir(
  appDir = system.file(path, package = "NGLVieweR", mustWork = TRUE),
  options = list(display.mode = "showcase")
)
}

Try the NGLVieweR package in your browser

Any scripts or data that you put into this service are public.

NGLVieweR documentation built on June 1, 2021, 9:08 a.m.