### Use setup_R.sh to Configure CRAN Mirror Source: https://rocker-project.org/images/versioned/r-ver.html Utilize the included setup_R.sh script in the rocker/r-ver image to configure a CRAN mirror, supporting binary installations from Posit Public Package Manager (P3M) and adapting to non-amd64 platforms. ```dockerfile FROM rocker/r-ver:4 RUN /rocker_scripts/setup_R.sh https://packagemanager.posit.co/cran/__linux__/jammy/2023-01-29 ``` -------------------------------- ### Configure P3M and CRAN Simultaneously in Dockerfile Source: https://rocker-project.org/images/versioned/r-ver.html Set up both Posit Public Package Manager (P3M) and CRAN as repositories in Rprofile.site within a Dockerfile. This ensures binary installations and successful package checks. ```dockerfile FROM rocker/r-ver:4 RUN echo 'options(repos = c(P3M = "https://packagemanager.posit.co/cran/__linux__/jammy/latest", CRAN = "https://cloud.r-project.org"))' >>"${R_HOME}/etc/Rprofile.site" ``` -------------------------------- ### Switch BLAS to libblas Source: https://rocker-project.org/images/versioned/r-ver.html Configure the system to use the reference BLAS implementation (libblas) instead of OpenBLAS. This is done using the update-alternatives command in the terminal. ```bash ARCH=$(uname -m) update-alternatives --set "libblas.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/blas/libblas.so.3" update-alternatives --set "liblapack.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/lapack/liblapack.so.3" ``` -------------------------------- ### Check Current BLAS Implementation in R Source: https://rocker-project.org/images/versioned/r-ver.html Display R session information, including the currently used BLAS library. This helps diagnose potential segfaults when using Python packages like numpy with R. ```r sessionInfo() #> R version 4.2.0 (2022-04-22) #> Platform: x86_64-pc-linux-gnu (64-bit) #> Running under: Ubuntu 20.04.4 LTS #> #> Matrix products: default #> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 #> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3 ``` -------------------------------- ### Switch BLAS to OpenBLAS Source: https://rocker-project.org/images/versioned/r-ver.html Revert the BLAS implementation back to OpenBLAS using the update-alternatives command. This command sets the symbolic links for libblas and liblapack to point to the OpenBLAS libraries. ```bash ARCH=$(uname -m) update-alternatives --set "libblas.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/openblas-pthread/libblas.so.3" update-alternatives --set "liblapack.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/openblas-pthread/liblapack.so.3" ``` -------------------------------- ### Set Default CRAN Mirror in Dockerfile Source: https://rocker-project.org/images/versioned/r-ver.html Configure the default CRAN mirror for R by adding an options setting to Rprofile.site within a Dockerfile. This ensures R uses the specified repository upon container startup. ```dockerfile FROM rocker/r-ver:4 RUN echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' >>"${R_HOME}/etc/Rprofile.site" ``` -------------------------------- ### Set Default CRAN Mirror as Non-Root User Source: https://rocker-project.org/images/versioned/r-ver.html Modify the default CRAN mirror from within a running container as a non-root user. This command pipes the options setting to the Rprofile.site file using sudo. ```bash echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' | sudo sh -c 'cat - >>"${R_HOME}/etc/Rprofile.site"' ``` -------------------------------- ### Temporarily Change CRAN Mirror in R Session Source: https://rocker-project.org/images/versioned/r-ver.html Adjust the CRAN mirror for the current R session using the options() function. This is useful for development tasks like package checking with devtools::check() to avoid '404 Not Found' errors. ```r options(repos = c(CRAN = "https://cloud.r-project.org")) devtools::check() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.