Errata

Hands-On Programming with R

Errata for Hands-On Programming with R

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 x, xi
x, 2nd paragraph; xi 4th paragraph in box

"judgement" is spelled judgment, at least in American English, though judgement is common in British English. I'll let you make the call.

guyrichard  May 04, 2015 
Chapter 7
the function "score" in the end

In Chapter 7, the function "score" didn't consider the situation "B BB DD" and "C C DD". It's not just the problem of doubling the prize, but to consider the "all same" and "all bars" situation.

For example, when it's "B BB DD", the prize should be 10, but not 0. Because "DD" may be "B", or "BB", or "BBB".

Johnny Wong  May 09, 2018 
Chapter 1
"The R User Interface" section, right before "Isn’t R a language?"

The example listing shows:

> 100:130 1
[1] 100 101 102 103 104 105 106 107 108 109 110 111 112
[14] 113 114 115 116 117 118 119 120 121 122 123 124 125
[25] 126 127 128 129 130

And the paragraph above it states:
"... These numbers just mean that the second line begins with the 14th value in the result, and the third line begins with the 25th value. ..."

The third line of the output in the listing should start with "[27]" and the sentence should read "... the third line begins with the 27th value."

Anonymous  Oct 07, 2019 
Chapter 2
In "LIBRARY" section, after figure 2-1

When describing the first example use of qplot(), there is a sentence which states:

"Together, the vectors x and y describe a set of 10 points."

This sentence should instead read:

"Together, the vectors x and y describe a set of 11 points."

Anonymous  Oct 07, 2019 
Chapter 3
Note 1 near end of "Loading Data" section

The note contains a sentence beginning with:

"To see a different number of rows, give head or tails a second argument..."

"tails" should instead be "tail".

Anonymous  Oct 08, 2019 
Chapter 8
Second paragraph of "Attributes" section

The paragraph reads:

"You can see an object’s attributes with attribute. If you run attribute on the DECK data frame that you created in Part II, you will see:"

The references to the "attribute" function should instead be "attributes". The paragraph should instead read:

"You can see an object’s attributes with attributes. If you run attributes on the DECK data frame..."

Anonymous  Oct 09, 2019 
Appendix E
Second paragraph of "trace" section

Third sentence reads: "R will prints trace:<the function>..."

"prints" should be "print".

Anonymous  Oct 16, 2019 
Environments
before figure 6.5

Environment is misspelled... see copy/paste below ...

Then you call the function. R responds by setting up a new runtime environment. This environment will be a child of the function’s origin enviornment. R will copy each of the function’s arguments into the runtime environment and then make the runtime environment the new active environment.

Lonnie Sanders III  Apr 09, 2022 
1 Chapter
Figure 1.4

Hi,

I think the figure 1.4 content should read [1] 1 4 3 8 5 12 instead of 1 4 4 6 6 8

Bye
Fabio

Anonymous  Nov 02, 2019 
Printed Page 5
2nd para

> 100:130
[1] 100 101 102 103 104 105 106 107 108 109 110 111 112
[14] 113 114 115 116 117 118 119 120 121 122 123 124 125
[25] 126 127 128 129 130

the above line [25] should be [27].

sreenivas vaddi  May 09, 2023 
Printed Page 11
Figure 1-4

1 + 1 = 1 should be 1 + 1 = 2

Lars Koewing  Feb 21, 2020 
Printed Page 22
Paragraph 4

'R packages, which are collections of functions WRITTED by R’s talented community of developers'

should be replaced with

'R packages, which are collections of functions WRITTEN by R’s talented community of developers'

Nicola Gnecco  Jan 28, 2017 
Printed Page 45
1st line after 2nd example

"or a 1 x 2 x 3 hypercube". Hypercube is probably not the best word for this matrix, since being 3D, the "hyper-" isn't needed, and the sides aren't equal, so not a cube.

Matthew  Feb 19, 2015 
Printed Page 46
1st and 2nd line of "arrays" section

"array" breaks across lines without hyphen

Matthew  Feb 19, 2015 
PDF Page 54
2nd paragraph

Typo: "[Lists] .. are used to create many more spohisticated types of R objects." should read "... sophisticated".

Heiko Korndorf  Jan 03, 2018 
Printed Page 56
Paragraph 4 and associated program listings

Not a mistake, just an update.

Default for stringsAsFactors was changed to stringsAsFactors = FALSE for data.frame() in R 4.0.0. Return for 'str(df)' and paragraph 4 are now incorrect.

Sarah Dowding  Dec 02, 2020 
Printed Page 56
middle

When typed in the command str(df), this is what I get:

> str(df)
'data.frame': 3 obs. of 3 variables:
$ face : chr "ace" "two" "six"
$ suit : chr "clubs" "clubs" "clubs"
$ value: num 1 2 3

Unlike what's in the book, I don't see the outputs with "Factor w/ 3 levels" but "chr" instead after $ face. What did I do wrong?

Jin Zhang  Jan 12, 2022 
Printed Page 85
Table 5-2, second line

Under syntax, the word "pipe" should be replaced by the pipe symbol: "cond1 | cond2"

Matthew  Feb 20, 2015 
PDF Page 87
United States

formula:
deal <- function(cards) {
cards[1,]
}

should be:
deal <- function(cards) {
deck[1,]
}

Diego  May 06, 2015 
PDF Page 87
United States

script:
deal <- function(cards) {
cards[1,]
}

should be:
deal <- function(cards) {
deck[1,]
}

Diego  May 06, 2015 
PDF Page 89
United States

script:
shuffle <- function(cards) {
random <- sample(1:52, size = 52)
cards[random, ]
}

should be:
shuffle <- function(cards) {
random <- sample(1:52, size = 52)
deck[random, ]
}

diego grant  May 06, 2015 
PDF Page 94
2nd paragraph and code underneath

The parenvs() function has been removed from devtools, because is now in the pryr package. Consequently, devtools should be replaced with pryr.

Adrian Danescu  Aug 12, 2020 
PDF Page 103
2nd paragraph

3rd sentence in the 2nd paragraph has environment misspelled as "enviornment."

Mani  Mar 09, 2015 
Printed Page 109
First line of setup function

on p 108 and 109, the setup function is created using an argument "deck". This causes a misbehaviour of the function "deal" later on.

It reads:
setup <- function(deck){
.
.
.
}

Later on page 109, the function is saved to the global environment (deal <- cards$deal). Using this function deals always the first card, it does not remove it from the deck after dealing.

To solve the problem, the setup function on top of page 109 could be changed like this:
setup <- function(){
.
.
.
}

Rafael Daniel Schlatter  Jan 01, 2018 
Printed Page 137
score function

The score function is not considering the wild card behavior of Diamonds.
For example when the sample returns c("DD","DD",7), the prize should calculate as 80, and then the code to "adjust for diamonds" should make it 320.

But since the wild card behavior of "DD" is not considered in the code, the prize returns 0, and the adjust for diamonds is of no use except for when the sample returns all "DD" s.

Sreehari Chandra  Feb 15, 2015 
PDF Page 180
Code example for get_many_symbols

The code mentioned is:

get_many_symbols <- function(n) {
wheel <- c("DD", "7", "BBB", "BB", "B", "C", "0")
vec <- sample(wheel, size = 3 * n, replace = TRUE,
prob = c(0.03, 0.03, 0.06, 0.1, 0.25, 0.01, 0.52))
matrix(vec, ncol = 3)
}

When in fact it should be:

get_many_symbols <- function(n) {
wheel <- c("DD", "7", "BBB", "BB", "B", "C", "0")
vec <- sample(wheel, size = 3 * n, replace = TRUE,
prob = c(0.03, 0.03, 0.06, 0.1, 0.25, 0.01, 0.52))
matrix(vec, ncol = 3, byrow = TRUE)
}

Jash Shah  Sep 12, 2016 
Printed Page 180
2nd line

342,308 seconds .. 5.7 minutes (inconsistent use of comma as decimal point).

Anonymous  Nov 23, 2016 
Printed Page 203
2nd paragraph

Update

With R 4.0.0, character strings are no longer converted to factors by default with read.table(). Paragraph is now inaccurate.

Sarah Dowding  Dec 03, 2020 
Other Digital Version 349
Figure 1-4, line 1

Kindle edition, location 349 of 7221:
Line 1 gives the result of 1 + 1 = 1. I think the result of 1 +1 is 2.

Anonymous  Apr 03, 2018