Add-On Packages
Over five thousand add-on packages are available for R, which serve a wide variety of purposes. An add-on package contains additional functions and sometimes objects such as example datasets. This appendix explains how to find a package that serves your purpose and install it.
Viewing a List of Available Add-on Packages
To view a list of available add-on packages, follow these instructions:
Figure A-1. List of mirror sites
A list of packages with descriptions of their purpose is displayed, as shown in Figure A-2. You can use the browser tools to search the list, usually by entering Ctrl+F or Cmd+F.
Figure A-2. List of available package sorted by name
On selecting a suitable package, you will see a package information page, as shown in Figure A-3. Here you will find a description of what the package does and a reference manual is available in pdf format. You will notice that the package is available to download, but you do not need to do this as it is simpler to install the package from within the R environment.
Figure A-3. Package information page for the lme4 package
Installing and Loading Add-On Packages
To use an add-on package, you must first install it, which only needs to be done once. There are a number of packages that are included with the R base installation (such as the foreign package that we used in Chapter 2), which do not need to be installed.
Once a package is installed, it must be loaded before you can use the functions within. The functions will be available for the remainder of the session, so you will need to load the package during each session that you intend to use it.
You can install and load packages from within the R environment, which is explained separately for Windows, Mac, and Linux users.
To install a package:
Figure A-4. Selecting a mirror site (Windows)
Figure A-5. Selecting a package to install (Windows)
To load a package:
To install a package:
Figure A-6. Selecting a package to install (Mac)
To load a package:
Note There is an issue in R version 3.1.0 for Mac which means that you may not be able to open the Package Manager. If you have this problem, you can download a patched version from http://r.research.att.com/. This should be resolved for versions 3.1.1 onwards.
Figure A-7. Loading a package (Mac)
To install a package:
> download.packages(packagename, "/home/Username/folder").
The file path gives the location in which to save the package
To load a package, enter the command:
> install.packages("packagename")
18.118.37.254