Skip to content

Latest commit

 

History

History
132 lines (98 loc) · 4.46 KB

README.md

File metadata and controls

132 lines (98 loc) · 4.46 KB

R packages (via pak) (r-packages)

Installs R packages via the pak R package's function. R must be already installed.

Example Usage

"features": {
    "ghcr.io/rocker-org/devcontainer-features/r-packages:1": {}
}

Options

Options Id Description Type Default Value
packages Comma separated list of packages to install to pass to the pak::pak() function. string -
pakVersion Version of pak to install. By default, the stable version is installed if needed. string auto
additionalRepositories String passed to the pak::repo_add() function. string -
installSystemRequirements Install packages' system requirements if available via pak::pak(). Converted to the PKG_SYSREQS env var during the installation. boolean false
cranMirror The CRAN mirror to use for installing packages. Converted to the PKG_CRAN_MIRROR env var if not empty. string -
notCran The 'NOT_CRAN' environment variable that is referenced during the installation of this Feature. boolean false

System Requirements

This Feature supports linux/amd64 and linux/arm64 platforms with R installed.

Please use this with an R-installed image (e.g. ghcr.io/rocker-org/devcontainer/r-ver) or this should be installed after installing Features that installs R (e.g. ghcr.io/rocker-org/devcontainer-features/r-apt, ghcr.io/rocker-org/devcontainer-features/r-rig).

"features": {
    "ghcr.io/rocker-org/devcontainer-features/r-rig:1": {},
    "ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
        "packages": "rlang"
    }
}

Note that source installation of the R packages may require the installation of additional build tools and system packages.

If many cases, we can use the installSystemRequirements option to install the system requirements automatically by pak::pak().

"features": {
    "ghcr.io/rocker-org/devcontainer-features/r-apt:latest": {},
    "ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
        "packages": "cli",
        "installSystemRequirements": true
    }
}

Or, for Debian and Ubuntu, we can use the ghcr.io/rocker-org/devcontainer-features/apt-packages Feature to install apt packages before installing this Feature.

"features": {
    "ghcr.io/rocker-org/devcontainer-features/r-apt:latest": {},
    "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
        "packages": "make,gcc,g++"
    },
    "ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
        "packages": "cli"
    }
}

How to specify packages?

Specify package names separated by commas in the packages option.

The following example installs cli and rlang.

"features": {
    "ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
        "packages": "cli,rlang"
    }
}

You can also specify packages on GitHub, etc. For example, the following example installs a package from https://github.com/r-lib/crayon.

"features": {
    "ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
        "packages": "github::r-lib/crayon"
    }
}

Please check the pak documentation for information on how to specify individual package names.

How to add other repositories?

Repositories can be set up as a string in R's named vector format.

For example, the following example runs as pak::repo_add(rhub = 'https://r-hub.r-universe.dev', jeroen = 'https://jeroen.r-universe.dev'); pak::pak("rversions").

"features": {
    "ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
        "packages": "rversions",
        "additionalRepositories": "rhub = 'https://r-hub.r-universe.dev', jeroen = 'https://jeroen.r-universe.dev'"
    }
}

See also

References


Note: This file was auto-generated from the devcontainer-feature.json. Add additional notes to a NOTES.md.