The R Project SVN R

Rev

Rev 59039 | Rev 77594 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59039 Rev 61160
Line 15... Line 15...
15
                 type = c("l", "p", "b", "o", "c"), legend = TRUE,
15
                 type = c("l", "p", "b", "o", "c"), legend = TRUE,
16
                 trace.label = deparse(substitute(trace.factor)),
16
                 trace.label = deparse(substitute(trace.factor)),
17
                 fixed = FALSE,
17
                 fixed = FALSE,
18
                 xlab = deparse(substitute(x.factor)),
18
                 xlab = deparse(substitute(x.factor)),
19
                 ylab = ylabel,
19
                 ylab = ylabel,
20
                 ylim = range(cells, na.rm=TRUE),
20
                 ylim = range(cells, na.rm = TRUE),
21
                 lty = nc:1, col = 1, pch = c(1:9, 0, letters),
21
                 lty = nc:1, col = 1, pch = c(1:9, 0, letters),
22
                 xpd = NULL, leg.bg = par("bg"), leg.bty = "n",
22
                 xpd = NULL, leg.bg = par("bg"), leg.bty = "n",
23
                 xtick = FALSE, xaxt = par("xaxt"), axes = TRUE,
23
                 xtick = FALSE, xaxt = par("xaxt"), axes = TRUE,
24
                 \dots)
24
                 \dots)
25
}
25
}
Line 78... Line 78...
78
 
78
 
79
\examples{
79
\examples{
80
require(graphics)
80
require(graphics)
81
 
81
 
82
with(ToothGrowth, {
82
with(ToothGrowth, {
83
interaction.plot(dose, supp, len, fixed=TRUE)
83
interaction.plot(dose, supp, len, fixed = TRUE)
84
dose <- ordered(dose)
84
dose <- ordered(dose)
85
interaction.plot(dose, supp, len, fixed=TRUE, col = 2:3, leg.bty = "o")
85
interaction.plot(dose, supp, len, fixed = TRUE, col = 2:3, leg.bty = "o")
86
interaction.plot(dose, supp, len, fixed=TRUE, col = 2:3, type = "p")
86
interaction.plot(dose, supp, len, fixed = TRUE, col = 2:3, type = "p")
87
})
87
})
88
 
88
 
89
with(OrchardSprays, {
89
with(OrchardSprays, {
90
  interaction.plot(treatment, rowpos, decrease)
90
  interaction.plot(treatment, rowpos, decrease)
91
  interaction.plot(rowpos, treatment, decrease, cex.axis=0.8)
91
  interaction.plot(rowpos, treatment, decrease, cex.axis = 0.8)
92
  ## order the rows by their mean effect
92
  ## order the rows by their mean effect
93
  rowpos <- factor(rowpos,
93
  rowpos <- factor(rowpos,
94
                   levels = sort.list(tapply(decrease, rowpos, mean)))
94
                   levels = sort.list(tapply(decrease, rowpos, mean)))
95
  interaction.plot(rowpos, treatment, decrease, col = 2:9, lty = 1)
95
  interaction.plot(rowpos, treatment, decrease, col = 2:9, lty = 1)
96
})
96
})
97
 
97
 
98
with(esoph, {
98
with(esoph, {
99
  interaction.plot(agegp, alcgp, ncases/ncontrols, main = "'esoph' Data")
99
  interaction.plot(agegp, alcgp, ncases/ncontrols, main = "'esoph' Data")
100
  interaction.plot(agegp, tobgp, ncases/ncontrols, trace.label="tobacco",
100
  interaction.plot(agegp, tobgp, ncases/ncontrols, trace.label = "tobacco",
101
                   fixed=TRUE, xaxt = "n")
101
                   fixed = TRUE, xaxt = "n")
102
})
102
})
103
## deal with NAs:
103
## deal with NAs:
104
esoph[66,] # second to last age group: 65-74
104
esoph[66,] # second to last age group: 65-74
105
esophNA <- esoph; esophNA$ncases[66] <- NA
105
esophNA <- esoph; esophNA$ncases[66] <- NA
106
with(esophNA, {
106
with(esophNA, {
107
  interaction.plot(agegp, alcgp, ncases/ncontrols, col= 2:5)
107
  interaction.plot(agegp, alcgp, ncases/ncontrols, col = 2:5)
108
                                # doesn't show *last* group either
108
                                # doesn't show *last* group either
109
  interaction.plot(agegp, alcgp, ncases/ncontrols, col= 2:5, type = "b")
109
  interaction.plot(agegp, alcgp, ncases/ncontrols, col = 2:5, type = "b")
110
  ## alternative take non-NA's  {"cheating"}
110
  ## alternative take non-NA's  {"cheating"}
111
  interaction.plot(agegp, alcgp, ncases/ncontrols, col= 2:5,
111
  interaction.plot(agegp, alcgp, ncases/ncontrols, col = 2:5,
112
                   fun = function(x) mean(x, na.rm=TRUE),
112
                   fun = function(x) mean(x, na.rm = TRUE),
113
                   sub = "function(x) mean(x, na.rm=TRUE)")
113
                   sub = "function(x) mean(x, na.rm=TRUE)")
114
})
114
})
115
rm(esophNA) # to clear up
115
rm(esophNA) # to clear up
116
}
116
}
117
\keyword{hplot}
117
\keyword{hplot}