]> nmode's Git Repositories - Rnaught/commitdiff
Add Shiny app dependencies add specify entry point
authorNaeem Model <me@nmode.ca>
Thu, 9 May 2024 20:34:03 +0000 (20:34 +0000)
committerNaeem Model <me@nmode.ca>
Thu, 9 May 2024 20:34:03 +0000 (20:34 +0000)
DESCRIPTION
NAMESPACE
R/app.R

index 586a1399f126be6834e02d46b1611e67a1825188..7a5b6e8c0b98923c6b39c815a937ece3a0b87c33 100644 (file)
@@ -11,16 +11,17 @@ Description: A collection of methods for estimating the basic reproduction
     number (R0) of infectious diseases. Optionally available as a web
     application using the 'shiny' framework.
 License: AGPL (>= 3)
     number (R0) of infectious diseases. Optionally available as a web
     application using the 'shiny' framework.
 License: AGPL (>= 3)
-URL: https://github.com/MI2Labs/Rnaught
-BugReports: https://github.com/MI2Labs/Rnaught/issues
+URL: https://github.com/MI2YorkU/Rnaught
+BugReports: https://github.com/MI2YorkU/Rnaught/issues
 Imports:
 Imports:
-    methods,
     stats,
     utils
 Suggests: 
     knitr,
     rmarkdown,
     stats,
     utils
 Suggests: 
     knitr,
     rmarkdown,
-    shiny
+    shiny,
+    bslib,
+    DT
 Encoding: UTF-8
 LazyData: true
 Roxygen: list(markdown = TRUE)
 Encoding: UTF-8
 LazyData: true
 Roxygen: list(markdown = TRUE)
index 42ad2823214d7295e246c8fedd0e52e97e4d6b73..1557cc12b14606247842880a39bd08354bfc8da0 100644 (file)
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -5,9 +5,6 @@ export(id)
 export(idea)
 export(seq_bayes)
 export(wp)
 export(idea)
 export(seq_bayes)
 export(wp)
-importFrom(methods,is)
 importFrom(stats,pgamma)
 importFrom(stats,qgamma)
 importFrom(utils,install.packages)
 importFrom(stats,pgamma)
 importFrom(stats,qgamma)
 importFrom(utils,install.packages)
-importFrom(utils,read.csv)
-importFrom(utils,write.csv)
diff --git a/R/app.R b/R/app.R
index 945f9e4634d61a2052d3d0ccde41071959b18d54..01f35b470ff5e13726a2186756f1c06bf2c0fbae 100644 (file)
--- a/R/app.R
+++ b/R/app.R
@@ -4,16 +4,33 @@
 #'
 #' @export
 app <- function() {
 #'
 #' @export
 app <- function() {
+  missing_pkgs <- c()
+  # Check for any missing, required packages.
   if (!requireNamespace("shiny", quietly = TRUE)) {
   if (!requireNamespace("shiny", quietly = TRUE)) {
-    answer <- readline(paste0("The package 'shiny' must be installed to ",
-      "launch the Rnaught web application.\nWould you like to install it? ",
-      "[Y/n] "))
+    missing_pkgs <- c(missing_pkgs, "shiny")
+  }
+  if (!requireNamespace("bslib", quietly = TRUE)) {
+    missing_pkgs <- c(missing_pkgs, "bslib")
+  }
+  if (!requireNamespace("DT", quietly = TRUE)) {
+    missing_pkgs <- c(missing_pkgs, "DT")
+  }
+
+  # If any of the required packages are missing,
+  # prompt the user to install them.
+  if (length(missing_pkgs) > 0) {
+    cat("The following packages must be installed to run the",
+      "Rnaught web application:\n"
+    )
+    writeLines(missing_pkgs)
+    answer <- readline("Begin installation? [Y/n] ")
 
 
-    if (answer == "Y" || answer == "y")
-      install.packages("shiny")
-    else
-      stop("Aborting.", call. = FALSE)
+    if (answer == "Y" || answer == "y") {
+      install.packages(missing_pkgs)
+    } else {
+      stop("Aborting due to missing, required packages.", call. = FALSE)
+    }
   }
 
   }
 
-  shiny::shinyApp(ui(), server)
+  shiny::runApp(appDir = system.file("app", package = "Rnaught"))
 }
 }