plotmeans.html 6.63 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Plot Group Means and Confidence Intervals</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>

<table width="100%" summary="page for plotmeans {gplots}"><tr><td>plotmeans {gplots}</td><td align="right">R Documentation</td></tr></table>
<h2>Plot Group Means and Confidence Intervals</h2>


<h3>Description</h3>

<p>
Plot group means and confidence intervals.
</p>


<h3>Usage</h3>

<pre>
plotmeans(formula, data=NULL, subset, na.action,
          bars=TRUE, p=0.95, minsd=0, minbar, maxbar,
          xlab=names(mf)[2], ylab=names(mf)[1], mean.labels=FALSE,
          ci.label=FALSE, n.label=TRUE, digits=getOption("digits"),
          col="black", barwidth=1, barcol="blue",
          connect=TRUE, ccol=col, legends=names(means), xaxt, use.t=TRUE, ...)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>formula</code></td>
<td>
symbolic expression specifying the outcome and grouping
variable.  See lm() for details.</td></tr>
<tr valign="top"><td><code>data</code></td>
<td>
optional data frame containing the variables in the model.</td></tr>
<tr valign="top"><td><code>subset</code></td>
<td>
an optional vector specifying a subset of observations to be
used in the fitting process.</td></tr>
<tr valign="top"><td><code>na.action</code></td>
<td>
a function which indicates what should happen when the data
contain `NA's.  See lm() for details. </td></tr>
<tr valign="top"><td><code>bars</code></td>
<td>
a logical value indicating whether confidence interval
bars should be plotted. Defaults to TRUE.</td></tr>
<tr valign="top"><td><code>p</code></td>
<td>
confidence level for error bars.  Defaults to 0.95.</td></tr>
<tr valign="top"><td><code>minsd</code></td>
<td>
minumum permitted value for the standard deviation within
each factor level.  Any standard deviation estimates smaller than
<code>minsd</code> will be replaced with <code>minsd</code>. Defaults to 0.</td></tr>
<tr valign="top"><td><code>minbar</code></td>
<td>
minumum allowed value for bar ends.  If specified,
values smaller than <code>minbar</code> will be replaced with
<code>minbar</code>. </td></tr>
<tr valign="top"><td><code>maxbar</code></td>
<td>
maximum allowed value for bar ends.  If specified,
values larger than <code>maxbar</code> will be replaced with
<code>maxbar</code>. </td></tr>
<tr valign="top"><td><code>xlab</code></td>
<td>
x-axis label.</td></tr>
<tr valign="top"><td><code>ylab</code></td>
<td>
y-axis label.</td></tr>
<tr valign="top"><td><code>mean.labels</code></td>
<td>
either a logical value indicating whether the circles
representing the group means should be replaced with text giving the
actual mean values or a vector containing labels to use
instead. Defaults to FALSE.</td></tr>
<tr valign="top"><td><code>ci.label</code></td>
<td>
a logical value indicating whether text giving the
actual interval end values should be placed at the end of each
confidence interval bar. Defaults to FALSE.</td></tr>
<tr valign="top"><td><code>n.label</code></td>
<td>
a logical value indicating whether text giving the number of
observations in each group should should be added to the plot. </td></tr>
<tr valign="top"><td><code>digits</code></td>
<td>
number of significant digits to use when displaying
mean or confidince limit values.</td></tr>
<tr valign="top"><td><code>col</code></td>
<td>
color of cicles marking group means.  Default is "black".</td></tr>
<tr valign="top"><td><code>barwidth</code></td>
<td>
linewidth of interval bars and end marks. Default is
1.</td></tr>
<tr valign="top"><td><code>barcol</code></td>
<td>
color of interval bars and end marks.  Default is
"blue".</td></tr>
<tr valign="top"><td><code>connect</code></td>
<td>
either a logical value indicating whether the means of
each group should be connected by a line, or a list of vectors giving the
index of bars that should be connected by a line. Defaults to TRUE.</td></tr>
<tr valign="top"><td><code>ccol</code></td>
<td>
color of lines used to connect means. Defaults to the
same color as "col".</td></tr>
<tr valign="top"><td><code>legends</code></td>
<td>
vector containing strings used to label groups along
the x axis. Defaults to group names.</td></tr>
<tr valign="top"><td><code>xaxt</code></td>
<td>
A character which specifies the axis type. Specifying `"n"'
causes an axis to be set up, but not plotted.</td></tr>
<tr valign="top"><td><code>use.t</code></td>
<td>
a logical value indicating whether the t distribution
should be used to compute confidence intervals.  If <code>TRUE</code>, the
default, a t distribution will the correct number of degrees of
freedom for each group be used.  If <code>FALSE</code>, the a normal
distribution will be used.</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
optional plotting parameters. </td></tr>
</table>

<h3>Author(s)</h3>

<p>
Gregory R. Warnes <a href="mailto:warnes@bst.rochester.edu">warnes@bst.rochester.edu</a>
</p>


<h3>See Also</h3>

<p>
<code><a href="plotCI.html">plotCI</a></code>, <code><a href="../../oligo/html/boxplot.html">boxplot</a></code>
</p>


<h3>Examples</h3>

<pre>

  # show comparison with boxplot
  data(state)
  plotmeans(state.area ~ state.region)   

  # show some color and mean labels
  plotmeans(state.area ~ state.region,
             mean.labels=TRUE, digits=-3,
             col="red", connect=FALSE)

  # show how to specify which means should be connected
  plotmeans(state.area ~ state.region, connect=list(1:2, 3:4),
            ccol="red", pch=7 )

  # more complicated example showing how to show an interaction
  data(esoph)  
  par(las=2,                        # use perpendicular axis labels
      mar=c(10.1,4.1,4.1,2.1),      # create enough space for long x labels
      mgp=c(8,1,0)                  # move x axis legend down to avoid overlap
      )
  plotmeans(ncases/ncontrols ~ interaction(agegp , alcgp, sep ="   "), 
            connect=list(1:6,7:12,13:18,19:24),
            barwidth=2,
            col="dark green",
            data=esoph,
            xlab="Age Group and Alcohol Consumption",
            ylab="# Cases / # Controls",
            main=c("Fraction of Cases for by Age and Alcohol Consumption",
                   "Ile-et-Vilaine Esophageal Cancer Study")
            )
  abline(v=c(6.5, 12.5, 18.5), lty=2)
  
</pre>



<hr><div align="center">[Package <em>gplots</em> version 2.3.2 <a href="00Index.html">Index]</a></div>

</body></html>