Main navigation

How to Run R

Input

You can use any text editor to make the appropriate input files for R. Rstudio, an IDE for R, can be used to prepare R scripts.

R Libraries

R includes a base package and additional add-on libraries. Several additional libraries have been installed. To see a list of the installed libraries, at the R command prompt, enter:

library()

Additional libraries can be installed in a personal R library directory. To install a library and its dependencies in this location you will need to run R interactively and issue at the R command line:

install.packages('package_name', dependencies=TRUE)

R will inform you that you can’t write to the global directory, and ask if you want to use a personal library instead. Say yes. R will then prompt you with a path and ask if you want to use this. Say yes. R will then install the library in this location.

See the R Installation and Administration guide for more information on how to customize the install.packages command (for example you could add the repository by including in the argument of your install.packages command the string: repos=”http://cran.r-project.org”).

To see a list of directories that R searches for libraries issue at the R prompt:

.libPaths()

Additional libraries, that are of relevant usage to the Hoffman2 community, can also be installed in the central repository upon request. See Software Installation.

How to Run R in Batch

How to Run R using the Queue Scripts

The easiest way to run R in batch from the login node is to use the queue scripts. See Running a Batch Job for a discussion of the queue scripts and how they are used.

The following queue script is available for building and submitting a serial R job:

R.q

How to Run R in Batch using UGE commands

See Running a Batch Job for guidelines to follow to create the required UGE command file. Alternatively, you could create an UGE command file with R.q. After saving the command file, you can modify it as necessary. See Commonly-Used UGE Commands for a list of the most commonly used UGE commands.

Your submission script will need to contain scheduler related information (see Commonly-Used UGE Commands) as well as instructions on how to run R, including the selection of a specific version of R.

  • For sh-based script use:

    . /u/local/Modules/default/init/modules.sh

  • For csh-based script use:

    source /u/local/Modules/default/init/modules.csh

  • followed by:

    module load R/XX.YY.ZZ
    R CMD BATCH filename

where XX.YY.ZZ is a specific version of R installed on the cluster (to see which versions are available issue at the command prompt: module av R) and filename is the name of the R script to be run.

Note: rJava

The R library rJava, a low-level R to Java interface, depends on the exact java version on the computing node. As it may happen that the default version of java on different computational nodes slightly differs (which may be due to an update in progress), rJava may appears to not work on some nodes. In this cases we suggest to modify the R command as follows:

  • For sh-based script use:

    . /u/local/Modules/default/init/modules.sh
    module load R
    R CMD javareconf -e
    R CMD BATCH filename

  • For csh-based script use:

    source /u/local/Modules/default/init/modules.csh
    module load R
    R CMD javareconf -e
    R CMD BATCH filename

 

How to Run R Interactively

How to Run R Interactively on the Hoffman2 cluster:

To run R interactively, first start an interactive session using qrsh.

At the compute node shell prompt, enter:

module load R
R

To see which versions of R are installed on the cluster use:

module av R

How to Run R Interactively from the UCLA Grid Portal

See How to Run an Application from the UCLA Grid Portal

References

Report Typos and Errors
UCLA OIT

© 2016 UC REGENTS TERMS OF USE & PRIVACY POLICY