The R Project SVN R

Rev

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