forked from mrdwab/koboloadeR
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathkobo_shiny.R
43 lines (38 loc) · 940 Bytes
/
kobo_shiny.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#' @name kobo_shiny
#' @rdname kobo_shiny
#' @title Shiny app launcher
#' @description A function to launch shiny apps
#'
#'
#' @param app script where shyni app is located
#'
#' @author Elliott Messeiller
#'
#'
#' @export kobo_shiny
#' @examples
#' \dontrun{
#' kobo_shiny(appname)
#' }
#'
#'
kobo_shiny <- function(app = "") {
mainDir <- kobo_getMainDirectory()
validApps <- list.files(system.file("shiny_app", package = "koboloadeR"))
validAppsMsg <-
paste0(
"Valid apps are: '",
paste(validApps, collapse = "', '"),
"'")
# if an invalid example is given, throw an error
if (missing(app) || !nzchar(app) || !app %in% validApps) {
stop(
"Please run 'kobo_shiny()' with a valid example app as an argument.\n",
validAppsMsg,
call. = FALSE)
}
# find and launch the app
appDir <- paste0(mainDir,"/code/shiny_app/",app)
shiny::runApp(appDir, display.mode = "normal")
}
NULL