The R Project SVN R

Rev

Rev 59039 | Rev 65208 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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