From f06d25f6319000070f7dd6777044c8127d53b073 Mon Sep 17 00:00:00 2001 From: Schultheis Date: Tue, 7 Apr 2020 10:21:58 +0200 Subject: [PATCH] auto-install missing dependencies --- wilson-basic/app.R | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/wilson-basic/app.R b/wilson-basic/app.R index ba37a02..ae49a64 100755 --- a/wilson-basic/app.R +++ b/wilson-basic/app.R @@ -3,15 +3,16 @@ # Basic App # -# Dependency check -if(!requireNamespace("wilson", quietly = TRUE)) { stop("The package wilson needs to be installed in order to use this app.")} -if(!requireNamespace("shinydashboard", quietly = TRUE)) { stop("The package shinydashboard needs to be installed in order to use this app.")} -if(!requireNamespace("shinythemes", quietly = TRUE)) { stop("The package shinythemes needs to be installed in order to use this app.")} -if(!requireNamespace("shinyBS", quietly = TRUE)) { stop("The package shinyBS needs to be installed in order to use this app.")} -if(!requireNamespace("htmltools", quietly = TRUE)) { stop("The package htmltools needs to be installed in order to use this app.")} +# Check and Load dependencies +dependencies <- c("wilson", "shiny", "shinydashboard", "shinythemes", "shinyBS", "shinyjs", "log4r") + +if (!requireNamespace("pacman", quietly = TRUE)) { + install.packages("pacman") +} +pacman::p_load(char = dependencies) # Set versions -wilson_app_version <- "WIlsON basic 2.1.0" +wilson_app_version <- "WIlsON basic 2.1.1" wilson_package_version <- as.character(packageVersion("wilson")) # @@ -25,7 +26,7 @@ wilson_mainpanelwidth <- Sys.getenv("WILSON_MAINPANELWIDTH", unset = 10) # Which page should the user land on - default is the Introdcution page wilson_landing_page <- Sys.getenv("WILSON_LANDING_PAGE", unset = "introduction") -if(!wilson_landing_page %in% c("introduction", "feature_selection")) { +if (!wilson_landing_page %in% c("introduction", "feature_selection")) { wilson_landing_page <- "introduction" } @@ -80,15 +81,6 @@ version_info <- paste0("---- VERSIONS ----\n", "App: ", wilson_app_version, "\n", "Package: ", wilson_package_version) -# Load packages -library(shiny) -library(shinydashboard) -library(shinyjs) -library(shinyBS) -library(shinythemes) -library(log4r) -library(wilson) - # Define the UI ui <- dashboardPage(header = dashboardHeader(disable = TRUE), sidebar = dashboardSidebar(disable = TRUE), body = dashboardBody(