
i
i
“K23166” — 2015/1/28 — 9:35 — page 133 — #159
i
i
i
i
i
i
8.5. SPECIAL-PURPOSE PLOTS 133
plot(x1, y, pch=" ") # create an empty plot of the correct size
abline(lm(y ~ x1, subset=x2==0), lty=1, lwd=2)
abline(lm(y ~ x1, subset=x2==1), lty=2, lwd=2)
...
abline(lm(y ~ x1, subset=x2==k), lty=k+1, lwd=2)
Note: The abline() function is used to generate lines for each of the subsets, with a solid
line (lty=1) for the first group and a dashed line (lty=2) for the second (this assumes
that X
2
takes on values 0–k, see 11.1.2). The plotFun() function in the mosaic package
provides another way of adding lines or arbitrary curves to a plot.
8.5.11 Kaplan–Meier plot
Example: ...