Request a space for the R libraries

Request a space for user maintained software for the R libraries.

Set up the R library paths and environment variables

Overview

If there is no existing ~/.Renviron, create it in the home directory and define where the R libraries will be. For an existing file ~/.Renviron that lists a custom-named default local library, define the new /usrapps directory first in a colon separated list. Additional libraries may have been installed in a home directory using the default R-named directory for local libraries, and that location does not have to be explicitly defined.

Steps

Create a text file ~/.Renviron containing the location of the libraries, e.g.:
R_LIBS=/usr/local/usrapps/[group]/[unityid]/libs/R

Do not use the library path /usr/local/usrapps/[group] directly because the group may want to install something other than R packages at some point. Create the directory before doing the installs; R_LIBS has to be an existing directory.

If you already have a custom directory in ~/.Renviron, add it after a colon, e.g.:
R_LIBS=/usr/local/usrapps/[group]/[unityid]/libs/R:/my/custom/Rlibs

To check whether R has defined the library paths as expected, open R and type:
.libPaths()

Example

Here is an example for user lllowe:

The /home/lllowe/.Renviron file contains:
R_LIBS=/share/Support/lllowe/libs/R:/home/lllowe/Rlibs

The output from .libPaths is below. The third line is the default local library named by R and the fourth is the location of the system installed R libraries.
> .libPaths() 
[1] "/gpfs_common/share01/Support/lllowe/libs/R" 
[2] "/home/lllowe/Rlibs" 
[3] "/home/lllowe/R/x86_64-pc-linux-gnu-library/3.5" 
[4] "/usr/local/apps/R/gcc_4.8.5/R-3.5.1/lib64/R/library" 

Install or load R libraries

Install or load R libraries as usual. For installs, new libraries will be installed in the first directory listed in the output of .libPaths(). For loading libraries, R will look for the library in order from first to last in directories defined in the output of .libPaths().

Copyright © 2024 · Office of Information Technology · NC State University · Raleigh, NC 27695 · Accessibility · Privacy · University Policies