Chapter 4: Code and download bundle

R Code

All verbatim chunk codes used in the Chapter are available in die.R. This file contains the code used in the production of the book, and may be used for reference. It will not be changed, and may fall behind current releases of R and contributed packages. A simplified, modified, file die_mod.R is also available, and will be kept up to date with reference to current R and contributed packages; it also will include/includes coloured figure code.

It is included in the chapter script and data sets bundle as a zip archive. The easiest way to reproduce the analyses in this chapter is to download and unzip the bundle, start R in the directory in which the bundle was unpacked, and say:

source("die_mod.R", echo=TRUE)

Note that some chapters involve very time-consuming analyses!

A posting on the R-sig-geo list includes an R code snippet for downloading all of the bundles.

It is possible to download the code for all chapters using this short R snippet:

ASDAR_BOOK <- "http://www.asdar-book.org/book"
chapters <- c("hello", "cm", "vis", "die", "cm2",
"csdacm", "sppa", "geos", "lat1", "lat2", "dismap")
# setwd() # move to download folder
for (i in chapters) {
fn <- paste(i, "mod.R", sep="_")
download.file(paste(ASDAR_BOOK, fn, sep = "/"), fn)
}
list.files()