R/run_app.R

Defines functions run_app

Documented in run_app

#' launch shiny app
#' @param app character string with the name of the app.
#' @param launchBrowser whether to launch the application with the browser or not.
#' @export
#' @examples
#' run_app('dataBrowser')
#'

run_app <- function(app,launchBrowser=T) {
  # locate all the shiny app examples that exist
  validExamples <- list.files(system.file("shinyApps", package = "SBR"))

  validExamplesMsg <-
    paste0(
      "Valid examples are: '",
      paste(validExamples, collapse = "', '"),
      "'")

  # if an invalid example is given, throw an error
  if (missing(app) || !nzchar(app) ||
      !app %in% validExamples) {
    stop(
      'Please run `run_app()` with a valid example app as an argument.\n',
      validExamplesMsg,
      call. = FALSE)
  }

  # find and launch the app
  appDir <- system.file("shinyApps", app, package = "SBR")

  shiny::runApp(appDir, display.mode = "normal",launch.browser = launchBrowser)

}
GiulioGenova/SBR documentation built on Feb. 25, 2020, 7:35 p.m.