R¶
R reaches all three products:
- Workbench runs it in sessions
- Connect runs it for deployed content, and
- Package Manager serves its packages and builds packages from Git.
This page collects each product's R settings in one place. Python has the matching page.
flowchart LR
Src["CRAN, Bioconductor,<br/>Git"] --> PPM("Package<br/>Manager")
PPM -->|"serves packages"| WB("Workbench<br/>sessions")
PPM -->|"serves packages"| Con("Connect<br/>content")
WB -->|"runs R from"| R[("<code>/opt/R</code>")]
Con -->|"runs R from"| R
style WB fill:#e8f1f8,stroke:#447099,stroke-width:2px,color:#1a1a1a
style Con fill:#fdf1e3,stroke:#c9822b,stroke-width:2px,color:#1a1a1a
style PPM fill:#e8f5ec,stroke:#3f8f5a,stroke-width:2px,color:#1a1a1a
R and Python terms¶
The two languages use different words for similar things, and some words (package, library) mean different things in each.
| Concept | R | Python |
|---|---|---|
| Unit you install | Package | Distribution package (what pip install installs)1 |
| Unit you load in code | Package, with library() or pkg::fun() |
Module or import package, with import1 |
| Directory of installed packages | Library (.libPaths())2 |
site-packages inside an environment3 |
| Isolated package set per project | renv project library4 |
Virtual environment (venv)3 |
| Lockfile | renv.lock |
requirements.txt with pinned versions |
| Public repository | CRAN, Bioconductor | PyPI |
| Install command | install.packages(), renv::restore() |
pip install, pip install -r requirements.txt |
| Repository setting | options(repos = ...) in Rprofile.site |
index-url in /etc/pip.conf5 |
| Prebuilt package | Binary package | Wheel |
| Source package | .tar.gz source package |
Source distribution (sdist)1 |
| Interpreter installs | /opt/R/<version> |
/opt/python/<version> |
Installing R¶
Install R from Posit's prebuilt binaries into /opt/R/<version>, one directory per version, and never upgrade a version in place.6 Package Manager's Linux binaries are built against those installations. Workbench and Connect both look for R under /opt/R.78
Workbench¶
Workbench lists the R versions it finds under /opt/R/<version> (r-versions-scan=1, the default), plus any listed in /etc/rstudio/r-versions.7 Turning off the scan does not hide the R on the PATH or the versions in r-versions. To restrict users to a set of versions, list them in r-versions and keep the others off the PATH.7
Set package repositories in two places:
rsession.conforrepos.conf: the default repositories for RStudio Pro sessions only.9posit-package-manager-urlinrserver.conf: the integration Package Manager recommends for RStudio Pro sessions. Do not combine it withr-cran-reposorrepos.conf.9Rprofile.sitein each R installation (/opt/R/<version>/lib/R/etc/Rprofile.site): repositories for R started anywhere, including Positron, VS Code, Jupyter,Rscript, and Workbench Jobs.9
Setting allow-r-cran-repos-edit=0 in rsession.conf hides the repository option in Global Options. Users can still pass repos = to install.packages().10
Connect¶
Connect scans /opt/R/<version> for R installations by default. To control exactly which versions are offered, list each one with R.Executable (the full path to the R binary).11 R.VersionMatching decides what happens when content asks for a version that is not installed: nearest (the default), major-minor, or exact.11
The block below turns off scanning, requires an exact version match, and lists one installation.
At deployment, Connect reads the R version and packages from the bundle's manifest.json and installs the packages from the configured repositories. It caches them by version under packrat/ in the data directory.12 Package installation always runs as the Applications.RunAs account.13 Configure repositories with [RPackageRepository] blocks; see Package Manager binaries.
See Connect.
Package Manager¶
Package Manager serves CRAN, Bioconductor, and internal R packages built from Git or uploaded as tarballs. On Linux, a repository URL with __linux__/<distro> serves binaries built for that distribution and R version. Package Manager reads the R version from R's user agent, which Rprofile.site sets.14 Server.RVersion is only used to build Git and local packages; it does not affect which binaries are served.15
See Linux binaries and Internal packages.