| 27442 |
ripley |
1 |
\name{plot.design}
|
|
|
2 |
\alias{plot.design}
|
|
|
3 |
\title{Plot Univariate Effects of a `Design' or Model}
|
|
|
4 |
\description{
|
|
|
5 |
Plot univariate effects of one ore more \code{\link{factor}}s,
|
| 27447 |
ripley |
6 |
typically for a designed experiment as analyzed by \code{\link[stats]{aov}()}.
|
| 27442 |
ripley |
7 |
Further, in S this a method of the \code{\link{plot}} generic function
|
|
|
8 |
for \code{design} objects.
|
|
|
9 |
}
|
|
|
10 |
\usage{
|
|
|
11 |
plot.design(x, y = NULL, fun = mean, data = NULL, \dots,
|
|
|
12 |
ylim = NULL, xlab = "Factors", ylab = NULL, main = NULL,
|
|
|
13 |
ask = NULL, xaxt = par("xaxt"), axes = TRUE, xtick = FALSE)
|
|
|
14 |
}
|
|
|
15 |
\arguments{
|
|
|
16 |
\item{x}{either a data frame containing the design factors and
|
| 27447 |
ripley |
17 |
optionally the response, or a \code{\link[stats]{formula}} or
|
|
|
18 |
\code{\link[stats]{terms}} object.}
|
| 27442 |
ripley |
19 |
\item{y}{the response, if not given in x.}
|
|
|
20 |
\item{fun}{a function (or name of one) to be applied to each
|
|
|
21 |
subset. It must return one number for a numeric (vector) input.}
|
|
|
22 |
\item{data}{data frame containing the variables referenced by \code{x}
|
|
|
23 |
when that is formula like.}
|
|
|
24 |
\item{\dots}{graphical arguments such as \code{col}, see \code{\link{par}}.}
|
|
|
25 |
\item{ylim}{range of y values, as in \code{\link{plot.default}}.}
|
|
|
26 |
\item{xlab}{x axis label, see \code{\link{title}}.}
|
|
|
27 |
\item{ylab}{y axis label with a \dQuote{smart} default.}
|
|
|
28 |
\item{main}{main title, see \code{\link{title}}.}
|
|
|
29 |
\item{ask}{logical indicating if the user should be asked before a new
|
|
|
30 |
page is started -- in the case of multiple y's.}
|
|
|
31 |
\item{xaxt}{character giving the type of x axis.}
|
|
|
32 |
\item{axes}{logical indicating if axes should be drawn.}
|
|
|
33 |
\item{xtick}{logical indicating if \dQuote{ticks} (one per factor) should
|
|
|
34 |
be drawn on the x axis.}
|
|
|
35 |
}
|
|
|
36 |
\details{
|
|
|
37 |
The supplied function will be called once for each level of each
|
|
|
38 |
factor in the design and the plot will show these summary values. The
|
|
|
39 |
levels of a particular factor are shown along a vertical line, and the
|
|
|
40 |
overall value of \code{fun()} for the response is drawn as a
|
|
|
41 |
horizontal line.
|
|
|
42 |
|
|
|
43 |
This is a new \R implementation which will not be completely
|
|
|
44 |
compatible to the earlier S implementations. This is not a bug but
|
|
|
45 |
might still change.
|
|
|
46 |
}
|
|
|
47 |
\references{
|
|
|
48 |
Chambers, J. M. and Hastie, T. J. eds (1992)
|
|
|
49 |
\emph{Statistical Models in S}.
|
|
|
50 |
Chapman & Hall, London, \bold{the} \emph{white book}, pp. 546--7 (and 163--4).
|
|
|
51 |
|
|
|
52 |
Freeny, A. E. and Landwehr, J. M. (1990)
|
|
|
53 |
Displays for data from large designed experiments;
|
|
|
54 |
Computer Science and Statistics: Proc.\ 22nd Symp\. Interface, 117--126,
|
|
|
55 |
Springer Verlag.
|
|
|
56 |
}
|
|
|
57 |
\author{Roberto Frisullo and Martin Maechler}
|
|
|
58 |
\note{A big effort was taken to make this closely compatible to the S
|
|
|
59 |
version. However, \code{col} (and \code{fg}) specification has
|
|
|
60 |
different effects.
|
|
|
61 |
}
|
| 27447 |
ripley |
62 |
\seealso{\code{\link[stats]{interaction.plot}} for a \dQuote{standard graphic}
|
| 27442 |
ripley |
63 |
of designed experiments.}
|
|
|
64 |
\examples{
|
|
|
65 |
data(warpbreaks)
|
|
|
66 |
plot.design(warpbreaks)# automatic for data frame with one numeric var.
|
|
|
67 |
|
|
|
68 |
Form <- breaks ~ wool + tension
|
|
|
69 |
summary(fm1 <- aov(Form, data = warpbreaks))
|
|
|
70 |
plot.design( Form, data = warpbreaks, col = 2)# same as above
|
|
|
71 |
|
|
|
72 |
## More than one y :
|
|
|
73 |
data(esoph)
|
| 27713 |
ripley |
74 |
utils::str(esoph)
|
| 27442 |
ripley |
75 |
plot.design(esoph) ## two plots; if interactive you are "ask"ed
|
|
|
76 |
|
|
|
77 |
## or rather, compare mean and median:
|
|
|
78 |
op <- par(mfcol = 1:2)
|
|
|
79 |
plot.design(ncases/ncontrols ~ ., data = esoph, ylim = c(0,0.8))
|
|
|
80 |
plot.design(ncases/ncontrols ~ ., data = esoph, ylim = c(0,0.8), fun = median)
|
|
|
81 |
par(op)
|
|
|
82 |
}
|
|
|
83 |
\keyword{hplot}
|
|
|
84 |
|