Skip to main content

Install packages from GitHub

R packages

When the visibility of a repository containing an R package is set to internal or private, you need to authenticate to GitHub to access it from R. Otherwise, you will get a 404 error.

The remotes package and the renv package allow you to install R packages using the same SSH credentials you use to close repositories from GitHub.

To install a package from an internal or private repository using remotes, you can use the following code:

remotes::install_git("git@github.com:moj-analytical-services/repository-name.git")

Alternatively, if you are using renv, you can use the following code:

renv::install("git@github.com:moj-analytical-services/repository-name.git")

In both cases, you should replace repository-name with the name of your repository.

You can use the same approach to install packages from any other public repository.

This page was last reviewed on 30 January 2023. It needs to be reviewed again on 30 January 2024 by the page owner #analytical-platform-support .
This page was set to be reviewed before 30 January 2024 by the page owner #analytical-platform-support. This might mean the content is out of date.