Book Image

R Object-oriented Programming

By : Kelly Black
Book Image

R Object-oriented Programming

By: Kelly Black

Overview of this book

Table of Contents (19 chapters)
R Object-oriented Programming
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Calculating Probabilities and Random Numbers
Package Management
Index

Appendix A. Package Management

A brief overview of working with packages is provided here. This is given as a reference to the basic commands used to manage packages. It is not exhaustive and serves only as a brief reference to manage packages associated with your installation of R.

The appendix has four parts:

  • An overview on how to access a package

  • An overview on how to install a package

  • An overview on how to remove a package

  • An overview on how to update packages

One of R's greatest strengths is the ability to use specialized packages, and a wide range of packages are available. Some of the packages are included in the regular installation, and some packages must be installed and maintained separately. We provide a brief overview of how to install, remove, and upgrade the installed packages on your system.

We first discuss two commands that are commonly used when working with packages. The first is the installed.packages command. This command will list all of the packages that are part of your installation. The other command is the library command. The library command is used to tell R to make use of the commands available in a given library. In the following example, the first command displays information about the splines package, and the second command must be entered before using the spline package:

> library(help = "splines")
> library(splines)

If a package is not part of your installation, you need to install it. The command to install a package is, oddly enough, the install.package command. In the following example, the car package, which is used for additional regression options, is installed. The full details are not provided. You must reply to a series of questions posed and then R will automatically fetch and install the package for you:

> install.packages("car")

A package can also be easily removed using the remove.packages command. In the following example, we remove the car package:

> remove.packages("car")

The last topic discussed is how to update your packages. To update all of your packages, simply use the update.packages command. In the following example, the command is entered and the full details are not provided. After submitting the command, you are given a list of packages that can be updated and you must decide which packages will be updated on your system:

> update.packages()