Errata

R Cookbook

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

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

Version Location Description Submitted By Date submitted Date corrected
PDF
Page 13
Figure 1-4. and the next paragraph

in the first paragraph:
"The two links in the Base R Reference section are especially useful:"

and there is no "Base R Reference" section in the Figure.

Note from the Author or Editor:
changed in GitHub https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Jul 05, 2019  Nov 15, 2019
PDF
Page 18
1 paragraph

the output of "help(package = "tseries")" is missing.

Note from the Author or Editor:
fixed in GitHub https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Jul 09, 2019  Nov 15, 2019
PDF
Page 106
5 paragraph

"Now the vector col_vec contains the column numbers of our named table,"

there is no vector name col_vec. According to the context, it should be table_range_col_num

pls check

Note from the Author or Editor:
fixed in GitHub https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Jul 14, 2019  Nov 15, 2019
Printed
Page 192
Solution of section 6.7

code in solution

df %>%
mutate(
case_when...

should be

df %>%
mutate(
my_field = case_when...

Note from the Author or Editor:
changed in GitHub commit https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

Ed Sweeney  Aug 17, 2019  Nov 15, 2019
PDF
Page 207
4nd paragraph

The example doesn't match the description

The description:

"The following example starts with the year/ month/day numbers for the third Wednesday in January of several years and then combines them all into Date objects:"

The example: ( note the dates doesn't look like 3rd Wed of Jan
years <- 2010:2014
months <- rep(1, 5)
days <- 5:9
ISOdate(years, months, days)
#> [1] "2010-01-05 12:00:00 GMT" "2011-01-06 12:00:00 GMT"
#> [3] "2012-01-07 12:00:00 GMT" "2013-01-08 12:00:00 GMT"
#> [5] "2014-01-09 12:00:00 GMT"
as.Date(ISOdate(years, months, days))
#> [1] "2010-01-05" "2011-01-06" "2012-01-07" "2013-01-08" "2014-01-09"

by the way, description here is matching with the example in the first edition of this book.

Note from the Author or Editor:
fixed in GitHub https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Jul 17, 2019  Nov 15, 2019
PDF
Page 345
2nd paragraph

in the summary the R2 values are:

"# Multiple R-squared: 0.885, Adjusted R-squared: 0.882"

in the description, says

"we would use 0.8815, not 0.8851"

the values are not match.

Note from the Author or Editor:
Confirmed and fixed in GitHub commit https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Aug 22, 2019  Nov 15, 2019
PDF
Page 418
last paragraph

in the last paragraph, there setup a example for pi simulation.

use 2,500,000 points

however, in the next page, in the example code and the result description

it becomes 5,000,000 points

Note from the Author or Editor:
confirmed and fixed wording in https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Jul 29, 2019  Nov 15, 2019
PDF
Page 419
2nd paragraph

in the 2nd paragraph:

"Now let’s take the exact same process but run it through future_map to run it in parallel:"

it says "exact same process"

it is muti-thread in the end as explained in the next paragraph



please clarify the wording for parallel tech.

Note from the Author or Editor:
fixed in https://github.com/CerebralMastication/R-Cookbook/commit/a695b5a82063fc539c4dddbb9b7d7fb422ee2ad2

RBK  Jul 29, 2019  Nov 15, 2019
PDF
Page 443
1 paragraph

The text under Figure 13-4 saying that "the first two components capture much of the variance..."

however, the Figure 13-4 shows only 1 component captures most of the variance.

pls check

Note from the Author or Editor:
confirmed as error. Changed in GitHub: https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Aug 23, 2019  Nov 15, 2019
PDF
Page 456
5nd paragraph

the first line of example code is duplicataed

"
Or use / to select ranges including months:
ibm['2009/201001'] # all of 2009 plus Jan 2010
ibm['2009/201001'] # all of 2009 plus Jan 2010 <<<<<<<
ibm['200906/201005'] # June 2009 through May 2010
"

Note from the Author or Editor:
fixed in GitHub https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Jul 30, 2019  Nov 15, 2019
PDF
Page 462
last paragraph

in the last paragraph:

"We can use the zoo function na.approx to fill our missing values using a cubic spline:"

na.approx is simple interpolation, and not in the example at all.

===================================
in the next paragraph:
"To get around this instability, we could get some data points from before January 1, 1999, then interpolate using na.spline, or we could simply choose a different interpolation method."

the function which performs spline is "na.spline"

===================================
however, i did a quick check, in zoo document, i can't find na.spline function??

https://www.rdocumentation.org/packages/zoo/versions/1.8-6



Note from the Author or Editor:
fixed in GitHub commit

https://github.com/CerebralMastication/R-Cookbook/commit/f853181a544ace16f53c817e33a6431f33d230c4

RBK  Jul 30, 2019  Nov 15, 2019