From 3a82fa736901897fe60122df9981b7a46cc148a0 Mon Sep 17 00:00:00 2001 From: Elodie Chapeaublanc <elodie.chapeaublanc@pasteur.fr> Date: Thu, 22 Aug 2024 14:59:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20=F0=9F=94=A7=20Modify=20configur?= =?UTF-8?q?ation=20file=20for=20installation=20of=20R=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/install_r_packages.R | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/install_r_packages.R b/scripts/install_r_packages.R index b7c4659..f3e42e9 100644 --- a/scripts/install_r_packages.R +++ b/scripts/install_r_packages.R @@ -1,10 +1,10 @@ #!/usr/bin/env Rscript ### Name : install_r_packages.R ### Folder : ~/scripts -### Date : 17/04/2023 +### Date : 22/08/2024 from previous version 17/04/2023 ### Aim : Install all packages from CRAN, BioConductor or github, requiered in the Shiny app. -### Install pak packages first +### Install some first pakcages included pak # Specify your packages my_packages <- c("pak","pkgcache","pkgdepends","pillar", "shinipsum") # Extract not installed packages @@ -18,16 +18,20 @@ if(length(not_installed)){ print("packages previously installed in the basic image") } -#### Load file with the list of packages -packages_list <- read.csv(file = "/opt/scripts/packages_to_install.csv", header = TRUE, sep = ";", stringsAsFactors = FALSE) +#### Load file with the list of packages for installation of supplementary packages +#### Part used in shiny-example docker images for install packages needed for shiny app +additional_packages <- read.csv(file = "/opt/scripts/packages_to_install.csv", header = TRUE, sep = ";", stringsAsFactors = FALSE) +packages_name <- additional_packages$Package_name +#### Selection of packages not yet installed +packages_needed <- packages_name[!(packages_name %in% installed.packages()[ , "Package"])] print("Installation for other packages needed : ") -print(paste(packages_list$Package_name, sep = "",collapse = ",")) +print(paste(packages_needed, sep = "",collapse = ",")) ### Install packages with dependencies with pak packages -for (i in 1:length(packages_list$Package_name)) { +for (i in 1:length(packages_needed)) { print("Installation of: ") - print(packages_list$Package_name[i]) - pak::pkg_install(pkg = packages_list$Package_name[i]) + print(packages_needed[i]) + pak::pkg_install(pkg = packages_needed[i]) print("Installation done!!") } # clean the cache of pak -- GitLab