R/runRPTS.R

#'  Appel des applications dédiées
#'
#'  @usage runRPTS(name)
#'
#' @param name string character indicating the name of the app to use.
#' @author Remy Moine <remymoine95@gmail.com>
#'
#'
#' @export
runRPTS <- function(name) {
  # locate all the shiny app examples that exist
  validExamples <- list.files(system.file("shiny-apps", package = "RPTS"))

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

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

  # find and launch the app
  appDir <- system.file("shiny-apps", name, package = "RPTS")
  shiny::runApp(appDir, display.mode = "normal")
}
remymoine/PTS-R-package documentation built on May 16, 2019, 5:03 a.m.