el-meyer / airship

AIRSHIP - An Interactive R-SHIny apP for visualizing tidy long data
https://el-meyer.github.io/airship/
GNU General Public License v3.0
3 stars 2 forks source link

Installation of missing dependencies #92

Closed majkamichal closed 1 year ago

majkamichal commented 1 year ago

See: https://github.com/majkamichal/easyPlot/issues/3

majkamichal commented 1 year ago

The airship() function should guide the user in case of missing dependencies. If some dependencies are missing then the app is not started. Instead, install.packages("") command is generated.


dependencies <- c("ggplot2", "shinyjs", "shinyAce", "shinyBS", "shinythemes", "Cairo", "DT", "colourpicker")

ind_missing_package <- !dependencies %in% utils::installed.packages()[ ,"Package"]

if (any(ind_missing_package)) { n_missing_packages <- sum(ind_missing_package) stop("Please install ", ifelse(n_missing_packages == 1, "the", "these"), " missing package", ifelse(n_missing_packages > 1, "s", ""), ":\n ", "install.packages(", ifelse(n_missing_packages > 1, "c(", ""), paste0("\"", dependencies[ind_missing_package], collapse = "\", "), ifelse(n_missing_packages > 1, "\"))", "\")")) }

majkamichal commented 1 year ago

Even if all dependencies were installed during the package installation process it could easily happen that a user removed some dependency (even by chance) and the app would crash.

el-meyer commented 1 year ago

Code was slightly adjusted.

Install dependencies --------

dependencies <- c( "shiny", "DT", "shinybusy", "plotly", "dplyr", "tidyselect", "tidyr", "stringr", "shinyBS", "colourpicker", "shinyWidgets", "shinydashboard", "scales", "Cairo", "ggplot2", "rlang", "magrittr" )

ind_missing_package <- !dependencies %in% utils::installed.packages()[ ,"Package"]

if (any(ind_missing_package)) { n_missing_packages <- sum(ind_missing_package) stop( "Some dependencies are missing. Please install ", ifelse( n_missing_packages == 1, "the", "these" ), " missing package", ifelse( n_missing_packages > 1, "s", "" ), " by running :\n ", "install.packages(", ifelse( n_missing_packages > 1, "c('", "'" ), paste0( "", dependencies[ind_missing_package], collapse = "','" ), ifelse( n_missing_packages > 1, "'))", "')" ) ) }