]> nmode's Git Repositories - Rnaught/blob - R/app.R
Create package help topic
[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("bslib", quietly = TRUE)) {
10 missing_pkgs <- c(missing_pkgs, "bslib")
11 }
12 if (!requireNamespace("shiny", quietly = TRUE)) {
13 missing_pkgs <- c(missing_pkgs, "shiny")
14 }
15 if (!requireNamespace("DT", quietly = TRUE)) {
16 missing_pkgs <- c(missing_pkgs, "DT")
17 }
18 if (!requireNamespace("plotly", quietly = TRUE)) {
19 missing_pkgs <- c(missing_pkgs, "plotly")
20 }
21
22 # If any of the required packages are missing,
23 # prompt the user to install them.
24 if (length(missing_pkgs) > 0) {
25 cat("The following packages must be installed to run the",
26 "Rnaught web application:\n"
27 )
28 writeLines(missing_pkgs)
29 answer <- readline("Begin installation? [Y/n] ")
30
31 if (answer == "Y" || answer == "y") {
32 install.packages(missing_pkgs)
33 } else {
34 stop("Aborting due to missing, required packages.", call. = FALSE)
35 }
36 }
37
38 shiny::runApp(appDir = system.file("app", package = "Rnaught"))
39 }