]>
nmode's Git Repositories - Rnaught/blob - R/web.R
1 #' Launch the Rnaught Web Application
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
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)
13 #' If any of the above packages are missing during launch, a prompt will appear
16 #' To configure settings such as the port, host or default browser, set Shiny's
17 #' global options (see [shiny::runApp()]).
19 #' @return A Shiny app object for the Rnaught web application.
21 #' @importFrom utils install.packages
26 # Check for any missing, required packages.
27 if (!requireNamespace("shiny", quietly
= TRUE)) {
28 missing_pkgs
<- c(missing_pkgs
, "shiny")
30 if (!requireNamespace("bslib", quietly
= TRUE)) {
31 missing_pkgs
<- c(missing_pkgs
, "bslib")
33 if (!requireNamespace("DT", quietly
= TRUE)) {
34 missing_pkgs
<- c(missing_pkgs
, "DT")
36 if (!requireNamespace("plotly", quietly
= TRUE)) {
37 missing_pkgs
<- c(missing_pkgs
, "plotly")
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"
46 writeLines(missing_pkgs
)
47 answer
<- readline("Begin installation? [Y/n] ")
49 if (answer
== "Y" || answer
== "y") {
50 install.packages(missing_pkgs
)
52 stop("Aborting due to missing, required packages.", call.
= FALSE)
56 shiny
::shinyAppDir(appDir
= system.file("web", package
= "Rnaught"))