-
Notifications
You must be signed in to change notification settings - Fork 0
/
ce_dashboard.R
46 lines (37 loc) · 1.31 KB
/
ce_dashboard.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
44
45
46
#' Run a Cost Effectiveness Interactive Dashboard
#'
#' @description This functions runs a dashboard that can be used to plot the results of cost effectiveness analysis.
#'
#' @return Starts a shiny dashboard
#' @export
#' @importFrom utils installed.packages
#' @examples
#'
#' ## Only run the example if in an interative session
#' \dontrun{
#'
#' ## Run the dashboard
#' ce_dashboard()
#' }
ce_dashboard <- function() {
required_packages <- c("shiny", "ceplotr")
not_present <- sapply(required_packages, function(package) {
not_present <- !(package %in% rownames(installed.packages()))
if (not_present) {
message(paste0(package,
" is required to use ce_dashboard, please install it before using this function"))
}
return(not_present)
}
)
if (any(not_present)) {
stop("Packages required for this dashboard are not installed,
please use the following code to install the required packages \n\n
install.packages(c('", paste(required_packages[not_present], collapse = "', '"), "'))")
}
appDir <- system.file("shiny", "ce_dashboard", package = "ceplotr")
if (appDir == "") {
stop("Could not find the ce_dashboard directory. Try re-installing `ceplotr`.", call. = FALSE)
}
shiny::runApp(appDir, display.mode = "normal")
}