]> nmode's Git Repositories - Rnaught/blob - R/web.R
Update about.html
[Rnaught] / R / web.R
1 #' Launch the Rnaught Web Application
2 #'
3 #' This is the entry point of the Rnaught web application, which creates and
4 #' returns a Shiny app object. When invoked directly, the web application is
5 #' launched.
6 #'
7 #' The following dependencies are required to run the application:
8 #' * [shiny](https://shiny.posit.co)
9 #' * [bslib](https://rstudio.github.io/bslib)
10 #' * [DT](https://rstudio.github.io/DT)
11 #' * [plotly](https://plotly-r.com)
12 #'
13 #' If any of the above packages are missing during launch, a prompt will appear
14 #' to install them.
15 #'
16 #' To configure settings such as the port, host or default browser, set Shiny's
17 #' global options (see [shiny::runApp()]).
18 #'
19 #' @return A Shiny app object for the Rnaught web application.
20 #'
21 #' @importFrom utils install.packages
22 #'
23 #' @export
24 web <- function() {
25 missing_pkgs <- c()
26 # Check for any missing, required packages.
27 if (!requireNamespace("shiny", quietly = TRUE)) {
28 missing_pkgs <- c(missing_pkgs, "shiny")
29 }
30 if (!requireNamespace("bslib", quietly = TRUE)) {
31 missing_pkgs <- c(missing_pkgs, "bslib")
32 }
33 if (!requireNamespace("DT", quietly = TRUE)) {
34 missing_pkgs <- c(missing_pkgs, "DT")
35 }
36 if (!requireNamespace("plotly", quietly = TRUE)) {
37 missing_pkgs <- c(missing_pkgs, "plotly")
38 }
39
40 # If any of the required packages are missing,
41 # prompt the user to install them.
42 if (length(missing_pkgs) > 0) {
43 cat("The following packages must be installed to run the",
44 "Rnaught web application:\n"
45 )
46 writeLines(missing_pkgs)
47 answer <- readline("Begin installation? [Y/n] ")
48
49 if (answer == "Y" || answer == "y") {
50 install.packages(missing_pkgs)
51 } else {
52 stop("Aborting due to missing, required packages.", call. = FALSE)
53 }
54 }
55
56 shiny::shinyAppDir(appDir = system.file("web", package = "Rnaught"))
57 }