While we did our best to ensure that R for Everyone was error free, a few mistakes did slip into the book, both in code and text.  The following is a list of known mistakes that occur in some printings of the book.

## Section 4.2 on page 37

When showing that the assignment operator <- can point to the right, the arrow was accidentally printed pointing to the left as:

> 3 <- z
> z
[1] 3

when it should be point to the right as:

> 3 -> z
> z
[1] 3

## Section 6.3 on Page 75

The following line mistakenly said that setting stringsAsFactors to TRUE would ave processing time whereas it should be FALSE.

Original:

Again, setting this to TRUE is usually a good idea, as it will save processing time and keep character data as character.

Corrected:

Again, setting this to FALSE is usually a good idea, as it will save processing time and keep character data as character.

## Section 15.2 on Page 193

GGally has been updated so that params argument in ggpairs is deprecated and its use will cause an error as below.

> data(economics, package='ggplot2')
> GGally::ggpairs(economics[, c(2, 4:6)], params=list(labelSize=8))
Error in stop_if_params_exist(params): 'params' is a deprecated argument.  Please 'wrap' the function to supply arguments. help("wrap", package = "GGally")

The fix is to call ggpairs without the params argument and use the ggplot2 function theme with axis.text set to ggplot2::element_text(size=2) to set the label text size.

> GGally::ggpairs(economics[, c(2, 4:6)]) + ggplot2::theme(axis.text=ggplot2::element_text(size=2))

## Section 19.2 on Page 293

Depending on the version of R and the arm package being used, using bayesglm with the subset argument can lead to an error as follows:

> resultsB <- vector(mode="list", length=length(theYears))
> names(resultsB) <- theYears
> for(i in theYears)
+ {
+     # fit model with Cauchy priors with a scale of 2.5
+     resultsB[[as.character(i)]] <-
+         arm::bayesglm(Vote ~ Race + Income + Gender + Education,
+                       data=ideo, subset=Year==i,
+                       prior.scale=2.5, prior.df=1)
+ }

Error in lm.fit(x = as.matrix(x[good.star, ]) * w.star, y = z.star * w.star) :
incompatible dimensions
In as.matrix(x[good.star, ]) * w.star :
longer object length is not a multiple of shorter object length



Not all users will experience this error as it is dependent on the version number of both R and arm. A simple workaround is to remove the subset argument and to subset the data using square bracket ([, ]) notation:

> resultsB <- vector(mode="list", length=length(theYears))
> names(resultsB) <- theYears
> for(i in theYears)
+ {
+     # fit model with Cauchy priors with a scale of 2.5
+     resultsB[[as.character(i)]] <-
+         arm::bayesglm(Vote ~ Race + Income + Gender + Education,
+                       data=ideo[ideo\$Year == i, ],
+                       prior.scale=2.5, prior.df=1)
+ }

## Section 21.3 on Page 328

There are two contradictory blocks of code to load the AT&T ticker data:

> require(quantmod)
> load("data/att.rdata")

and

> require(quantmod)
> att <- getSymbols("T", auto.assign=FALSE)

The block containing load is a misprint and should be ignored. To correctly obtain the data run the block that uses getSymbols to download the data from the Internet:

> require(quantmod)
> att <- getSymbols("T", auto.assign=FALSE)

## Section 22.2 on Page 347

For reasons unknown the World Bank has removed the zip file of the world map shapefile and its new location is unclear. In the meantime, a copy of the zip file has been posted at http://jaredlander.com/data/worldmap.zip.

The original code

> download.file(url="http://maps.worldbank.org/overlays/2712.zip", destfile="data/worldmap.zip", method="curl")

should be replace with:

> download.file(url="http://jaredlander.com/data/worldmap.zip", destfile="data/worldmap.zip", method="curl")

## Section 24.2.2 on Page 377

In copies from the first printing the wrong function is output when running the print command without parenthesis. The editions with error look like:

> print
standardGeneric for "print" defined from package "base"

function (x, ...)
standardGeneric("print")
<environment: 0x000000000c3dcdc0>
Methods may be defined for arguments: x
Use  showMethods("print")  for currently available ones.

That is for an S4 version of print. The intent was to show the S3 version as follows:

> print
function (x, ...)
UseMethod("print")
<bytecode: 0x00000000081e2bb0>
<environment: namespace:base>

## Appendix A.7 on Page 394

The book The Elements of Statistical Learning is erroneously attributed to Hastie, Tibshirani and Hastie when it should be Hastie, Tibshirani and Friedman.

## Index of People on Page 433

In the first printing the index incorrectly lists Trevor Tibshirani rather than Robert Tibshirani.

Jared Lander is the Chief Data Scientist of Lander Analytics a New York data science firm, Adjunct Professor at Columbia University, Organizer of the New York Open Statistical Programming meetup and the New York and Washington DC R Conferences and author of R for Everyone.