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.
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.
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.
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.
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!
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.