School of Statistics

Image of Goldy Gopher and link to School of Statistics

Wordmark of and link to University of Minnesota
Applied Linear Regression, 3rd Ed.
Using R -- Revised January 2011

New in January 2011!

The alr3 package for R

If you are running R, connected to the internet, and have write privileges on your computer's disk, you can install alr3 by typing the following command in the R command window:

> install.packages("alr3", dependencies=TRUE)

Setting dependencies=TRUE causes car and other packages needed to be downloaded and installed. You may be prompted to select a location for the download; pick a site close to your home. After this, the package should install itself. You do not need to install again unless you upgrade to a newer version of R.

To use the alr3 package you simply enter the library command in R:

> library(alr3)

All other needed packages, including car, are loaded automatically.

The R primer and the alrWeb function

The R primer has been updated to correspond to the new versions of alr3 and car. If you are connected to the internet when using R, the easiest way to get the R primer is to start R, and then enter the following two commands:

> library(alr3)
> alrWeb("primer")

If you prefer, you can download the R primer from here.

The command alrWeb() opens your browser at this website. The command alrWeb("errata") opens the Errata sheet for the book.

Chapter and Primer R Scripts

Scripts of R commands that produce nearly all the computations in the book and all the computations discussed in the R primer can be obtained with a command like

> alrWeb(script="chapter1"))

The value of script can be any of chapter1, chapter2, ... , chapter12, appendix, for the 12 chapters and appendix in the textbook, or primer0, primer1 primer12, ... , primer12, for the corresponding chapters in the R primer including the introductory Chatper 0, or primerappendix for the appendix to the R primer.

If you prefer,

New Stuff in alr3

  1. You no longer need to use the data function to access a data set from the alr3 package; all data sets are accessible when you use the library command to load alr3.
  2. The data files are unchanged, except that occasionally row names have been added. The forbes data now masks a file of the same name in the MASS package, with slightly different variable names but the same data. The longley data file has been removed, as a file of the same name with the same data is part of the standard R distribution.
  3. Most of the functions that were previously part of alr3 have been moved to the car package, and almost all of these functions have different names for consistency within car. Most of the new functions have the same arguments as the old ones. A notable exception is the powerTransform function which replaces the old bcpower function and has completely different arguments; see help("powerTransform"). To get a listing of the functions that have moved, enter help("alr3-deprecated").

R resources

From
www.r-project.org, the home for R, you can get a wealth of information about R, including books and other documentation, access to CRAN (pronounced "see-ran"), which includes the program and many add-on packages, and other interesting stuff. The help files available from the R Help menu are also useful.