#' Run one of the shiny examples available in the package
#'
#' @param example Valid name of a Shiny examples
run_shiny_example <- function(example) {
# locate all the shiny app examples that exist
validExamples <- list.files(system.file("shiny-examples", package = "tradeAnalysis"))
validExamplesMsg <-
paste0(
"Valid examples are: '",
paste(validExamples, collapse = "', '"),
"'")
# if an invalid example is given, throw an error
if (missing(example) || !nzchar(example) ||
!example %in% validExamples) {
stop(
'Please run `run_shiny_example()` with a valid example app as an argument.\n',
validExamplesMsg,
call. = FALSE)
}
# find and launch the app
appDir <- system.file("shiny-examples", example, package = "tradeAnalysis")
shiny::runApp(appDir, display.mode = "normal")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.