Configuring R Environments#
Once you have obtained the repository URL, your environment must be configured to use the URL to download and install packages.
Base R#
To configure R to use Package Manager as its CRAN repository, set the repos
option to use the repository URL:
Alternatively, instead of replacing your default URL, additional repositories can be added to your existing configuration. For example:
local({
repos <- c(PackageManager = "https://packagemanager.posit.co/cran/__linux__/centos7/latest")
repos["LocalPackages"] <- "https://packagemanager.posit.co/local/__linux__/centos7/latest"
# add the new repositories first, but keep the existing ones
options(repos = c(repos, getOption("repos")))
})
# verify the current repository list
getOption("repos")
<< PackageManager
<< "https://packagemanager.posit.co/cran/__linux__/centos7/latest"
<< LocalPackages
<< "https://packagemanager.posit.co/local/__linux__/centos7/latest"
<< CRAN
<< "https://cloud.r-project.org"
The same code can be added to your R startup file (Rprofile.site
or .Rprofile
) to maintain the repository configuration across R sessions. See our article on managing R startup files for more information.
Tip
If you are installing packages on Linux and want to take advantage of pre-built binary packages for speed and reliability, follow the instructions in Configuring the R User Agent Header to set up or verify your configuration.
RStudio Desktop or Posit Workbench#
In RStudio Desktop or Posit Workbench, repository settings are configured through the Global Options menu available from the Tools section of the main toolbar.
From the left pane, click Packages , paste the repository URL into the Primary CRAN repository field or click Add to include this repository as a secondary repository.
Your Posit Workbench administrator can also configure the default repository for all users to point to Package Manager. See Configuring Posit Workbench for more information.