This article is based on this section of the administrator's guide.
RStudio Connect offers a flexible way of deploying your Shiny applications and R Markdown content against a variety of R versions.
A compatible version of R is identified when content is deployed. That R installation is used any time R is needed for that content. Package installation, starting a Shiny application, and rendering R Markdown documents will all use the version of R discovered at deploy-time.
RStudio Connect allows different content to rely on different versions of R. For example, Alice’s R Markdown document may require version 3.2.4 of R while Bob’s Shiny application needs R version 3.3.1. Those two deployments using different R versions can coexist in RStudio Connect without conflict.
This chapter discusses RStudio Connect can be configured to support more than one version of R and how R version compatibility is determined.
Available R installations are analyzed at startup. Connect logs the discovered R versions. Connect will fail to start if no R installation can be found.
Changing any of the configuration items discussed in this chapter requires a restart of RStudio Connect.
Installing R
The recommended approach to installing R on RStudio Connect is documented here.
R versions
RStudio Connect supports two ways of discovering R versions: scanning well-known locations and through direct configuration. Connect will use the PATH environment variable to discover a version of R if one is not otherwise found.
Scanning
RStudio Connect can automatically scan for versions of R in the following locations:
/usr/lib/R
/usr/lib64/R
/usr/local/lib/R
/usr/local/lib64/R
/opt/local/lib/R
/opt/local/lib64/R
In addition, Connect scans all subdirectories of the following directories within /opt
:
/opt/R
/opt/local/R
For example, any of the following installed versions of R will be automatically detected:
/opt/R/3.1.3
/opt/R/3.2.4
/opt/local/R/3.3.1
Scanning happens by default. You can disable version scanning by customizing the Server.RVersionScanning
property.
[Server]
RVersionScanning = false
R Versions
The Server.RVersion
property can be used to specify alternate locations for installations of R. Specify this property once for each R installation directory.
[Server]
RVersion = /shared/R/3.3.1
RVersion = /shared/R/3.2.4
RVersion = /shared/R/3.1.3
Excluding versions
If you have versions of R that are picked up by automatic scanning but which you would like to exclude, disable R version scanning and explicitly specify all versions you would like to use with the Server.RVersion
configuration property.
Here is an example configuration that disables scanning, and specifies precisely two R versions that will be available for use.
[Server]
RVersionScanning = false
RVersion = /opt/R/3.3.1
RVersion = /opt/R/3.2.4
R Version Matching
RStudio Connect attempts to find an R installation that is appropriate for your content. By default, it applies a “nearest” matching approach. This algorithm attempts to always find a version of R to use with your content. More deployments will succeed but not always with the same version of R that is used by the author.
If you would prefer a strict association between authored and deployed R versions, you can choose to use an “exact” matching approach.
The “nearest” matching algorithm is the most flexible option and favors publication of your content over precise duplication of the authoring environment.
The “major-minor” algorithm is a middle ground between “nearest” and “exact”. It requires exact MAJOR.MINOR
matching but is flexible about the patch level. This is a useful option when your desktop and server may occasionally have different update cycles when installing bug fix releases.
An inconsistent version of R occasionally causes problems when installing package dependencies. For the best results, make sure that RStudio Connect has access to the same versions of R used to author content.
The R version matching approach is controlled with the Server.RVersionMatching
configuration setting.
- nearest
-
Find an R installation that is close to the version of R used when authoring the Shiny application or R Markdown document. This algorithm uses the ordered tests when looking for
MAJOR.MINOR.PATCH
version matches:- Use exact version match.
- If there are matching
MAJOR.MINOR
releases, use least-greater version. - If there are matching
MAJOR.MINOR
releases, use latest of these. - Use least-greater version across all releases.
- Use latest across all releases.
- major-minor
-
Find an R installation that is close to the version of R used when authoring the Shiny application or R Markdown document requiring an exact
MAJOR.MINOR
version match. If a compatible version cannot be found, content will fail to deploy. The algorithm is a constrained “nearest” search:- Use exact version match.
- If there are matching
MAJOR.MINOR
releases, use least-greater version. - If there are matching
MAJOR.MINOR
releases, use latest of these.
- exact
- Finds an R installation that exactly matches the version of R used when authoring the deployed content. If a matching version cannot be found, content will fail to deploy.
Comments