Using R Packages on SSCC Computers

Much of R's utility comes from packages that users have written. Base R comes with some packages, but you may need to install more.

Installing and Loading Packages

In Windows R, you install a package by clicking Packages, Install Package(s). You'll then be asked the mirror to install from (it makes little difference, but the nearest to Madison is probably USA (IA), located in Iowa) and the package you want to install. You'll get a warning that the program can't modify an HTML file that keeps a list of installed packages, but that won't prevent you from using the package.

In Linux R type:


where package should be replaced by the name of the package you want to install. You'll again be asked for the mirror to install from.

To load the package in Windows R, click Packages, Load Package and then the name of the package you want to load.

In Linux R, type:


In future sessions you'll only need to load the package, not install it again.

Updating Packages

You should check periodically to see if any of the packages you use have been updated.

In Windows R, click Packages, Update Packages.

In Linux R, type:


Managing Packages

By default, R on SSCC computers puts packages in your home directory (U: in Windows or ~ in Linux). If you work with a lot of packages this will clutter your home directory. You can change where R packages are stored by doing the following:

Create a Directory

First make a directory to store packages. In Windows, create a folder call R_packages on your U: drive. In Linux, create a directory called R_packages in your home directory by typing:

mkdir ~/R_packages

Configure R to Use the Directory

For Windows R, open a text editor like TextPad or Notepad (not Word). Type:


Note that the slash is a forward slash, not the backslash normally used in Windows. Save the file on your U: drive as .Rprofile, making sure the file name doesn't have .txt at the end.

For Linux R, open your preferred Linux text editor if you have one, or TextPad in Windows. Type


then save the file as .Rprofile in your Linux home directory. If you're using TextPad that means you must save it on your Z: drive.

Once this file is created, packages will be saved in the directory R_packages instead of your home directory. If you have installed packages previously, move them into R_packages or install them again.

Last Revised: 11/9/2009