Skip to content
Snippets Groups Projects
Commit 3a82fa73 authored by Elodie  CHAPEAUBLANC's avatar Elodie CHAPEAUBLANC
Browse files

:package: :wrench: Modify configuration file for installation of R packages

parent 431abbc1
Branches docker-images
No related tags found
No related merge requests found
Pipeline #137635 passed
Pipeline: shiny-k8s-example

#137645

    Pipeline: shiny-k8s-example

    #137644

      Pipeline: shiny-k8s-example

      #137637

        #!/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
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment