Skip to content

Latest commit

 

History

History

R

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

R

Container definition files for using the R programming langauge, grouped by specialty.

These containers are based on the Rocker pre-built containers. For more information about Rocker and the containers they provide, see here.

Choosing the version of R

These recipes are based on the Rocker container images on DockerHub: https://hub.docker.com/u/rocker. Generally, you can change the "tag" in the From line to specify the version of R that you want to use. For example,

# Apptainer .def file
From: rocker/r-ver:4.1
# Dockerfile
FROM rocker/r-ver:4.1

will build the container using the r-ver container with R version 4.1.

How to install packages

There are two ways that you can pass the R commands in the container build file. You may encounter either approach in the container recipe files here.

1. Single line command

You can pass a command directly to R for execution with the syntax

    R -e "command to execute"

For example,

    R -e "install.packages(c('cowsay','fortunes'), dependencies=TRUE, repos='http://cran.rstudio.com/')"

installs the cowsay and fortunes packages. This approach is useful for simple commands, but does not handle nested quotations well.

2. Create an install script

You can create a short install script written in R that you can execute using Rscript. This uses a special syntax:

    cat << EOF > install.R
command1
command2
..
command3
EOF

    Rscript install.R

(and similarly for Dockerfiles).

The lines between cat << EOF and EOF will be written to install.R, which will then be executed using Rscript.

Note that the second EOF must not have any characters before or after it on the same line!

Using a different base operating system

The base operating system for the Rocker containers is Debian Linux. If you want to use a different operating system, you can install R using Conda. See our Conda recipes and follow the instructions here.