diff options
author | Naeem Model <me@nmode.ca> | 2023-07-25 01:50:09 +0000 |
---|---|---|
committer | Naeem Model <me@nmode.ca> | 2023-07-25 01:50:09 +0000 |
commit | 1d15746821b536ef60d6b86e475bf0057d98e8bd (patch) | |
tree | 6a8dc6d11c6f698e62de938463f43631a13e6494 /R | |
parent | 91465cd1193400053a48cca196d3fd777183c82c (diff) |
Prompt user to install optional dependency
Diffstat (limited to 'R')
-rw-r--r-- | R/app.R | 16 | ||||
-rw-r--r-- | R/ui.R | 4 |
2 files changed, 15 insertions, 5 deletions
@@ -1,9 +1,19 @@ #' Launch the Rnaught Web Application #' +#' @importFrom utils install.packages +#' #' @export app <- function() { - if (!requireNamespace("shiny", quietly = TRUE)) - stop("The package 'shiny' must be installed to launch the Rnaught web application.") + 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] ")) + + if (answer == "Y" || answer == "y") + install.packages("shiny") + else + stop("Aborting.", call. = FALSE) + } - shiny::shinyApp(ui, server) + shiny::shinyApp(ui(), server) } @@ -1,4 +1,4 @@ -ui <- shiny::fluidPage( +ui <- function() { shiny::fluidPage( # Title. shiny::titlePanel(shiny::HTML( paste0("Rnaught: An Estimation Suite for R", shiny::tags$sub("0")))), @@ -194,4 +194,4 @@ ui <- shiny::fluidPage( ) ) ) -) +)} |