R Packages

This is information for people who wish to add R packages for their own use. If you find an R package missing that you believe is of wide interest or you need for teaching, please email ithelp@stats.ox.ac.uk with a request for it to be installed (on a specific set of systems).

The information here is current for R 2.5.0: it has changed since R 2.4.1.

Windows users
Only packages needed for teaching are installed for everyone. To install a package for your own use, you need to set up a personal library (a folder where packages are stored): you will be asked to create this when you first install a package, or you can create it yourself (see the R on Windows FAQ section  Q4.2).

You can install packages from the Packages > Install package(s)... menu item. This will first ask you for a CRAN mirror -- we recommend you select 'UK (Bristol)'.

It then presents a list of about a thousand packages. Just select packages in the usual Windows way (left click for the first, ctrl-left click to add or remove) and click on 'OK'.

These, and any other packages they need to work, will be downloaded and installed to your personal library, and be available for use immediately.

Updating installed packages
To check if there are updates to your personal packages, use the command

      update.packages(.libPaths()[1], ask="graphics")

select a CRAN mirror and then select packages for update from the list box offered (if any).

Finally if you want to check that packages have been installed then the command

      library()

will list all available packages.

If you have previously installed packages in earlier version of R you may have files such as .Renviron and .Rprofile which will need to be revised or removed before packages install successfully. 

Fixing the help pages problem
With packages that you install for yourself the help(function, package=FOO) doesn’t work. The help browser window reports an error “Navigation to the webpage was canceled”.
To fix this you need to:
- Double click on STATS icon on your desktop
- Double click on Homes folder
- Double click on R folder
- Double click on win-library folder
- Double click on 2.5 folder
You should then see a list of all packages you have installed. Browse to each of these packages and delete the folder called chtml. Then when you run help you will get a text-based version of the help files.

There is further information about installing source packages in Windows here.

 

Linux users
First ensure that you are seeing the full range of packages which are installed centrally. Check that the command

      library()

produces a list of about 1200 packages. (If not, you probably have a local version of R installed, and need to use /usr/local/bin/R to start R.) All the CRAN and Bioconductor packages that we are able to install should be there and are updated at least weekly.

If you wish to install your own packages from elsewhere, all you need to do is, in R,

      install.packages(c(pkg1,pkg2))

So to install the binom and bayesmix packages you should enter

      install.packages(c("binom","bayesmix"))

This will set up a personal library for you if needed (it will ask for confirmation), then ask you to select a CRAN mirror (we recommend that you choose 'UK (London)'), download the source packages and install them ready for use.

Finally if you want to check that packages have been installed then the command

      library()

will list all available packages by library.

The same procedure will work on ix86 and x86_64 Linux, but different personal libraries will be used as the architectures need different binaries. They are of the form

    ~/R/i686-pc-linux-gnu-library/2.5
    ~/R/x86_64-unknown-linux-gnu-library/2.5

Note that the personal library path includes the major.minor version of R: when this changes you are expected to reinstall the packages. To check if there are updates to your personal packages, use

      update.packages(.libPaths()[1])

in R, select a CRAN mirror and then answer the questions (if any).