Errata

R in a Nutshell

Errata for R in a Nutshell

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 23
3rd paragraph

The description of what the = assignment operator does is incorrect. The text says that it assigns the symbol on the left to the object on the right. It should say "This operator assigns the value of the symbol on the right to the object on the left."

Leonor M. Abraido-Fandino  Feb 12, 2013 
Printed Page 53
Footnote 1

The footnote is incorrect. It says that the expression `[<-`(animals, 4, "duck") does not print the result on the R console. However, it does in fact print the result. The equivalent statement, animals[4] = "duck", is the one that does not print the result on the R console.

Leonor M. Abraido-Fandino  Feb 13, 2013 
Printed Page 66
# modulus

The result of the modulus example has a typo. There should be no question mark, ?, after the 20.

Leonor M. Abraido-Fandino  Feb 13, 2013 
PDF Page 68
last paragraph

For the list of the built-in operators, user should look at the help file for Syntax, not syntax, i.e., ?Syntax.

Carlos Gamero  Dec 04, 2015 
Printed Page 70
Example at the bottom of the page

'Error: object "v" not found' appears only if v is not defined in the current environment. But if you've tried the examples on p. 69, where v is defined and modified to be a two-dimensional array, and then you run the example at the bottom of p. 70, asking for v's value will print

[,1] [,2] [,3] [,4]
[1,] 1 3 5 7
[2,] 2 10 6 8

Leonor M. Abraido-Fandino  Feb 13, 2013 
Printed Page 71
if (is(x, "numeric")) x/2 else print("x is not numeric")

The result of this conditional statement is 0.5, not 5, because x was assigned the value of 1 on the examples on p. 70.

Leonor M. Abraido-Fandino  Feb 13, 2013 
PDF Page 71
Line 29

if (is(x, "numeric")) x/2 else print("x is not numeric")
the output of this conditional statements maybe 0.5 not the 5.
because the latest value of x is "{x <- 1; y <- 2; x + y}"

Anonymous  Feb 15, 2013 
PDF Page 72
Definitions of the "switcheroo" functions

In the definition of switcheroo.if.then, if x == "a" then "camel" is printed. However, in the switcheroo.switch function, a = "alligator". When the functions are then run in the next section down, switcheroo.if.then("a") returns "camel" (correctly, according to its definition, if not alliteratively), but switcheroo.switch("a") incorrectly returns "camel".

If you want your alliteration to work, "a" should return "alligator" in both function definitions, and in the example down the page. If you want a single fix, change "alligator" to "camel" in switcheroo.switch's definition.

Matt Morrison  Jan 12, 2013 
Printed Page 72
Definitions of the "switcheroo" functions

mm1173's comments on p. 72 of the PDF version also apply to p. 72 of the printed version.

Leonor M. Abraido-Fandino  Feb 13, 2013 
PDF Page 72
3rd paragraph

> switcheroo.switch <- function(x) {
+ switch(x,
+ a="alligator",
+ b="bear",
+ c="camel",
+ "moose")
+ }

here alligator should be camel

Anonymous  Feb 15, 2013 
PDF Page 75
1st

before these codes
> sqrts.1to5 <- foreach(i=1:5) %do% sqrt(i)
> sqrts.1to5

maybe add the line of code
library("foreach")

Anonymous  Feb 15, 2013 
Printed Page 78
Result of v[rep(c(TRUE, FALSE), 10)]

The result of this indexing operation is incorrect. A prior example on this page sets and prints v as follows.

> v <- 1:12
> v[15] <- 15
> v
[1] 1 2 3 4 5 6 7 8 9 10 11 12 NA NA 15

So v[rep(c(TRUE, FALSE), 10)] evaluates to

[1] 1 3 5 7 9 11 NA 15 NA NA

Leonor M. Abraido-Fandino  Feb 13, 2013 
Printed Page 78
Result of v[(v %% 3 == 0)]

The result is wrong. In a prior example on the same page, v was set and printed with the following.

> v <- 1:12
> v[15] <- 15
> v
[1] 1 2 3 4 5 6 7 8 9 10 11 12 NA NA 15

So v[(v %% 3 == 0)] returns the following.

[1] 3 6 9 12 NA NA 15

Leonor M. Abraido-Fandino  Feb 13, 2013 
PDF Page 78
5th paragraph

Add the line of code
v <- 100:119
before the code
rep(c(TRUE, FALSE), 10)
is the alternative method.

even though, please give the output of the code
v[(v==103)]
is
[1] 103

Anonymous  Feb 15, 2013 
Printed Page 79
Result of v[c(TRUE, FALSE, FALSE)]

The result is wrong. An example on p. 78 sets and prints v as follows.

> v <- 1:12
> v[15] <- 15
> v
[1] 1 2 3 4 5 6 7 8 9 10 11 12 NA NA 15

So v[c(TRUE, FALSE, FALSE)] returns

[1] 1 4 7 10 NA

Leonor M. Abraido-Fandino  Feb 13, 2013 
PDF Page 90 of pdf and (112 of 722)
last code in the page

eye.colors was used to describe factor
and survey.results was used to describe the factors using levels.

So, the unclass example should work for survey.results.
If we use unclass and print the output on eye.colors, it doesn't print the levels but it prints the elements of the factor eye.colors.

When we use unclass on survey.results, it prints the output as shown in the book.


Thank you.

Anonymous  Feb 10, 2013 
PDF Page 91
The Last paragraph

In the last line
+ "Los Angeles", "Richardson"),
The comma is redundant.

Anonymous  Feb 15, 2013 
PDF Page 100 of pdf and (122 of 722)
First Code

As mentioned in the errata submitted earlier, the levels were not described for eye.colors.integer.vector.

So, the output is wrong.

Anonymous  Feb 10, 2013 
PDF Page 163
middle

In short, I got no tables in sqlTables(ddbd). I have a 64 bit machine - is this the reason? any other idea?

more details:
=========

I did the odbcConnect and the reply to odbcGetInfo looks OK - see below, but then it claims no table.

> sqlTables(bbdb)
[1] TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS
<0 rows> (or 0-length row.names)

> odbcGetInfo(bbdb)
DBMS_Name
"SQLite"
DBMS_Ver
"3.8.6"
Driver_ODBC_Ver
"03.00"
Data_Source_Name
"bbdb"
Driver_Name
"sqlite3odbc.dll"
Driver_Ver
"0.999"
ODBC_Ver
"03.80.0000"
Server_Name
"C:\\Users\\eitan\\Documents\\R\\win-library\\3.1\\nutshell.bbdb\\extdata\\bb.db"

(the path is ok)

Thanks!

Eitan  Oct 28, 2014 
PDF Page 177/(199 of 722)
dow30.tickers

The symbol declared is dow.tickers but while passing, dow30.tickers is used in the line

dow30 <- get.multiple.quotes(dow30.tickers)

Anonymous  Feb 14, 2013 
Printed Page 360
Last paragraph of section on Principal Components Analysis

Last paragraph of section on Principal Components Analysis, page 360. I
believe the two references to *princomp* is really meant to be
references to *prcomp*.

Anonymous  Dec 06, 2012 
Printed, PDF Page 382
Testing for Normality - Codes

R Code to plot both plot:

hist(fg_attempts$yards, breaks=25) -> should be:
hist(field.goals$yards, breaks=25)

qqnorm(fg_attempts$yards, pch=".") -> should be:
qqnorm(field.goals$yards, pch=".")

Nico  Jan 25, 2013 
PDF Page 402
third code block

The invocations of attach(), make.groups(), and detach() have a final semicolon, which is unnecessary.

John Posner  Dec 01, 2014 
PDF Page 527
Here is the code I used to read in the data...

We need to add to the prefix ".gz" to generate the filenames.

paste(GSE2034[strata(GSE2034,
stratanames="relapse",
size=c(50,50),
method="srswor")$ID_unit,
]$GEO.asscession.number,
".CEL.gz",
sep="")

Also, in the second line of page 528 we also need to add the ".gz" to clean up the sample names:
sub("\\.CEL.gz$","",sampleNames(GSE2034.fromcel.smpl))

Nico

Nico  Feb 11, 2013 
PDF Page 527
code

Page 527
GSE2034[strata(GSE2034,

Should be:

GSE2034[sampling::strata(GSE2034,


Page 537

smpl <- sampling::strata


To avoid problem in case the reader has the ?survival? library used in chapter 20 loaded .

Page 536

First paragraph: ?from the anaffy package. Should be annaffy to have access to the aaf.handler()

Will be useful if this chapter starts by explanining how to install all the packages needed from the bioconductor.

source("http://bioconductor.org/biocLite.R")
biocLite(c("sampling","annotate","affy","annaffy","genefilter","GEOquery","hgu133a.db","simpleaffy","rbsurv","vsn"))

Rafael Nicolas Fermin  Feb 15, 2013 
Other Digital Version 13604
after the line "We can use bootstrap to look at how biased median is as an estimator

The dataset home.sale.prices.june2008 does not exist in the nutshell package.

Please note, page number is the location in Amazon Kindle edition

Jeegen  Jan 25, 2013