Set Up Steps:
Website: http://www.r-project.org/
License: GNU GPL 2.0
Tips:
There are different distributions of R for different versions of Linux. Find and obtain the correct package for your version here, along with version specific instructions:
Follow the instructions in this topic to configure R within LabKey Server:
Authentication. If you wish to modify a password-protected LabKey Server database through the Rlabkey macros, you will need to set up authentication. See: Create a netrc file.
Permissions. Refer to Configure Permissions for information on how to adjust the permissions necessary to create and edit R Views. Note that only users who have the "Editor" role (or higher) plus either one of the developer roles "Platform Developer" or "Trusted Analyst" can create and edit R reports. Learn more here: Developer Roles.
Batch Mode. Scripts are executed in batch mode, so a new instance of R is started up each time a script is executed. The instance of R is run using the same privileges as the LabKey Server, so care must be taken to ensure that security settings (see above) are set accordingly. Packages must be re-loaded at the start of every script because each script is run in a new instance of R.
You will likely need additional packages to add functionality that basic install does not include. Additional details on CRAN packages are available here:
Each package needs to be installed AND loaded. Packages only need to be installed once on your LabKey Server. However, they will need to be loaded at the start of every script when running in batch mode.How to Install R Packages
Use the R command line or a script (including a LabKey R script) to install packages. For example, use the following to install two useful packages, "GDD" and "Cairo":
install.packages(c("GDD", "Cairo"), repos="http://cran.r-project.org" )
To install knitr:
install.packages('knitr', dependencies=TRUE)
You can also use the R GUI (Packages > Install Packages) to select and install packages.
How to Load
If the installed package is not set up as part of your native R environment (check 'R_HOME/site-library'), it needs to be loaded every time you start an R session. Typically, when running R from the LabKey interface, you will need to load (but not install) packages at the start of every script because each script is run in a new instance of R.
To load an installed package (e.g., Cairo), call:
library(Cairo)
To determine which packages are installed and what their versions are, use the guidance in this topic.