| Line 5... |
Line 5... |
| 5 |
Plots the mean (or other summary) of the response for two-way
|
5 |
Plots the mean (or other summary) of the response for two-way
|
| 6 |
combinations of factors, thereby illustrating possible interactions.
|
6 |
combinations of factors, thereby illustrating possible interactions.
|
| 7 |
}
|
7 |
}
|
| 8 |
\usage{
|
8 |
\usage{
|
| 9 |
interaction.plot(x.factor, trace.factor, response, fun = mean,
|
9 |
interaction.plot(x.factor, trace.factor, response, fun = mean,
|
| 10 |
type = c("l", "p"), legend = TRUE,
|
10 |
type = c("l", "p", "b"), legend = TRUE,
|
| 11 |
trace.label=deparse(substitute(trace.factor)), fixed=FALSE,
|
11 |
trace.label=deparse(substitute(trace.factor)), fixed=FALSE,
|
| 12 |
xlab = deparse(substitute(x.factor)), ylab = ylabel,
|
12 |
xlab = deparse(substitute(x.factor)), ylab = ylabel,
|
| 13 |
ylim = range(cells, na.rm=TRUE),
|
13 |
ylim = range(cells, na.rm=TRUE),
|
| 14 |
lty = nc:1, col = 1, pch = c(1:9, 0, letters),
|
14 |
lty = nc:1, col = 1, pch = c(1:9, 0, letters),
|
| 15 |
xpd = NULL, leg.bg = par("bg"), leg.bty = "n",
|
15 |
xpd = NULL, leg.bg = par("bg"), leg.bty = "n",
|
| Line 70... |
Line 70... |
| 70 |
\examples{
|
70 |
\examples{
|
| 71 |
attach(ToothGrowth)
|
71 |
attach(ToothGrowth)
|
| 72 |
interaction.plot(dose, supp, len, fixed=TRUE)
|
72 |
interaction.plot(dose, supp, len, fixed=TRUE)
|
| 73 |
dose <- ordered(dose)
|
73 |
dose <- ordered(dose)
|
| 74 |
interaction.plot(dose, supp, len, fixed=TRUE, col = 2:3, leg.bty = "o")
|
74 |
interaction.plot(dose, supp, len, fixed=TRUE, col = 2:3, leg.bty = "o")
|
| - |
|
75 |
interaction.plot(dose, supp, len, fixed=TRUE, col = 2:3, type = "p")
|
| 75 |
detach()
|
76 |
detach()
|
| 76 |
|
77 |
|
| 77 |
with(OrchardSprays, {
|
78 |
with(OrchardSprays, {
|
| 78 |
interaction.plot(treatment, rowpos, decrease)
|
79 |
interaction.plot(treatment, rowpos, decrease)
|
| 79 |
interaction.plot(rowpos, treatment, decrease, cex.axis=0.8)
|
80 |
interaction.plot(rowpos, treatment, decrease, cex.axis=0.8)
|
| Line 84... |
Line 85... |
| 84 |
|
85 |
|
| 85 |
with(esoph, {
|
86 |
with(esoph, {
|
| 86 |
interaction.plot(agegp, alcgp, ncases/ncontrols)
|
87 |
interaction.plot(agegp, alcgp, ncases/ncontrols)
|
| 87 |
interaction.plot(agegp, tobgp, ncases/ncontrols, trace.label="tobacco",
|
88 |
interaction.plot(agegp, tobgp, ncases/ncontrols, trace.label="tobacco",
|
| 88 |
fixed=TRUE, xaxt = "n")
|
89 |
fixed=TRUE, xaxt = "n")
|
| - |
|
90 |
## deal with NAs:
|
| - |
|
91 |
esoph[66,] # second to last age group: 65-74
|
| - |
|
92 |
ncases[66] <- NA
|
| - |
|
93 |
interaction.plot(agegp, alcgp, ncases/ncontrols, col= 2:5)
|
| - |
|
94 |
# doesn't show *last* group either
|
| - |
|
95 |
interaction.plot(agegp, alcgp, ncases/ncontrols, col= 2:5, type = "b")
|
| - |
|
96 |
## alternative take non-NA's {"cheating"}
|
| - |
|
97 |
interaction.plot(agegp, alcgp, ncases/ncontrols, col= 2:5,
|
| - |
|
98 |
fun = function(x) mean(x,na.rm=TRUE))
|
| 89 |
})
|
99 |
})
|
| 90 |
}
|
100 |
}
|
| 91 |
\keyword{hplot}
|
101 |
\keyword{hplot}
|