
i
i
“K23166” — 2015/1/28 — 9:35 — page 167 — #193
i
i
i
i
i
i
Chapter 11
Special topics
In this chapter, we demonstrate some key programming and statistical techniques that
statisticians may encounter in daily practice.
11.1 Processing by group
One of the most common needs in analytic practice is to replicate analyses for subgroups
within the data. For example, one may need to stratify a linear regression by gender or
repeat a modeling exercise multiple times for each replicate in a simulation experiment. The
basic tools for replication in base R include the by() function and the apply() family of
functions (A.5.2). The syntax for these functions can be complicated, ...