Install and load R packages on Big Red II at IU

R is a language and environment for statistical computing and graphics. R provides a wide variety of statistical (e.g., linear and nonlinear modeling, classical statistical tests, time-series analysis, classification, and clustering) and graphical techniques, and is highly extensible. For more, see the R Project for Statistical Computing home page.

To use R on Big Red II, you first must add it to your user environment; for instructions, see Use R on Big Red II at IU.

On this page:


Install R packages

You can install R packages in your Big Red II home directory using either of the following methods. Before you begin, create a subdirectory for your package (e.g., ~/r-packages); on the command line, enter:

  mkdir r-packages
  • Installing from a locally stored source file: To use a package source file stored in your Big Red II home directory (e.g., ~/my_r_pkg) to install an R package to your R package subdirectory (e.g., ~/r-packages), on the command line, enter:
      R CMD INSTALL my_r_pkg -l ~/r-packages
    
  • Installing from the CRAN package repository: To download and install a package (e.g., my_r_pkg) from the CRAN package repository and install it in your R package subdirectory (e.g., ~/r-packages), launch R, and then, at the R command prompt (>, enter:
      install.packages("my_r_pkg", lib="~/r-packages/")
    

Continue to Load R packages.

Load R packages

In R, to load your newly installed package (e.g., ~/r-packages/my_r_pkg), at the R command prompt, enter:

  library("my_r_pkg", lib.loc="~/r-packages/")

For more details, type ?INSTALL in the R console.

Get help

If you have questions about using statistical and mathematical software at Indiana University, contact Research Analytics. Research Analytics is located on the IU Bloomington campus at Woodburn Hall 200; staff are available for consultation Monday-Friday 9am-noon and by appointment.

This is document bfrs in the Knowledge Base.
Last modified on 2018-01-26 11:05:39.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.