]> nmode's Git Repositories - Rnaught/blob - R/app.R
Update COVID-19 Canada datasets
[Rnaught] / R / app.R
1 #' Launch the Rnaught Web Application
2 #'
3 #' @importFrom utils install.packages
4 #'
5 #' @export
6 app <- function() {
7 missing_pkgs <- c()
8 # Check for any missing, required packages.
9 if (!requireNamespace("shiny", quietly = TRUE)) {
10 missing_pkgs <- c(missing_pkgs, "shiny")
11 }
12 if (!requireNamespace("bslib", quietly = TRUE)) {
13 missing_pkgs <- c(missing_pkgs, "bslib")
14 }
15 if (!requireNamespace("DT", quietly = TRUE)) {
16 missing_pkgs <- c(missing_pkgs, "DT")
17 }
18
19 # If any of the required packages are missing,
20 # prompt the user to install them.
21 if (length(missing_pkgs) > 0) {
22 cat("The following packages must be installed to run the",
23 "Rnaught web application:\n"
24 )
25 writeLines(missing_pkgs)
26 answer <- readline("Begin installation? [Y/n] ")
27
28 if (answer == "Y" || answer == "y") {
29 install.packages(missing_pkgs)
30 } else {
31 stop("Aborting due to missing, required packages.", call. = FALSE)
32 }
33 }
34
35 shiny::runApp(appDir = system.file("app", package = "Rnaught"))
36 }