
i
i
“K23166” — 2015/1/28 — 9:35 — page 187 — #213
i
i
i
i
i
i
Chapter 12
Case studies
In this chapter, we explore several case studies that demonstrate the statistical computing
strengths and potential of R. This includes data management tasks, reading more complex
files, creating maps, data scraping, using the shiny system within RStudio, manipulating
larger datasets, and solving an optimization problem.
12.1 Data management and related tasks
12.1.1 Finding two closest values in a vector
Suppose we need to find the closest pair of observations for some variable. This might arise
if we were concerned that some data had been accidentally duplicated. In this case ...