[R-gregmisc-commits] r2133 - in pkg/gplots: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Aug 12 19:18:33 CEST 2016
Author: warnes
Date: 2016-08-12 19:18:32 +0200 (Fri, 12 Aug 2016)
New Revision: 2133
Modified:
pkg/gplots/R/plotmeans.R
pkg/gplots/man/plotmeans.Rd
Log:
New parameter 'add' for plotmeans to allow *adding* means+confidence intervals to an existing plot.
Modified: pkg/gplots/R/plotmeans.R
===================================================================
--- pkg/gplots/R/plotmeans.R 2016-08-12 17:17:24 UTC (rev 2132)
+++ pkg/gplots/R/plotmeans.R 2016-08-12 17:18:32 UTC (rev 2133)
@@ -17,6 +17,7 @@
xaxt,
use.t = TRUE,
lwd=par("lwd"),
+ add = FALSE,
...)
{
if (invalid(formula) || (length(formula) != 3))
@@ -51,6 +52,7 @@
if(!bars)
{
+ if(add) par(new=TRUE)
plot( means, ..., col=col, xlim=xlim)
}
else
@@ -77,7 +79,8 @@
plotCI(x=1:length(means), y=means, uiw=ci.width, xaxt="n",
xlab=xlab, ylab=ylab, labels=mean.labels, col=col, xlim=xlim,
- lwd=barwidth, barcol=barcol, minbar=minbar, maxbar=maxbar, ... )
+ lwd=barwidth, barcol=barcol, minbar=minbar, maxbar=maxbar,
+ add=add, ... )
if(invalid(xaxt) || xaxt!="n")
axis(1, at = 1:length(means), labels = legends, ...)
Modified: pkg/gplots/man/plotmeans.Rd
===================================================================
--- pkg/gplots/man/plotmeans.Rd 2016-08-12 17:17:24 UTC (rev 2132)
+++ pkg/gplots/man/plotmeans.Rd 2016-08-12 17:18:32 UTC (rev 2133)
@@ -10,7 +10,7 @@
digits=getOption("digits"), col="black", barwidth=1,
barcol="blue", connect=TRUE, ccol=
col, legends=names(means), xaxt, use.t=TRUE,
- lwd=par("lwd"), ...)
+ lwd=par("lwd"), add = FALSE, ...)
}
\arguments{
\item{formula}{symbolic expression specifying the outcome (continuous)
@@ -91,6 +91,9 @@
\item{lwd}{Width of connecting lines }
+ \item{add}{Logical specifying whether to add to an existing plot
+ (\code{add=TRUE}) or to generate a new plot (\code{add=FALSE}).}
+
\item{\dots}{ optional plotting parameters. }
}
@@ -133,7 +136,29 @@
"Ile-et-Vilaine Esophageal Cancer Study")
)
abline(v=c(6.5, 12.5, 18.5), lty=2)
+ grid()
+ # add to a boxplot
+ boxplot(ncases/ncontrols ~ interaction(agegp , alcgp, sep =" "),
+ 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"),
+ ylim=c(-0.75, 1.5),
+ col="green"
+ )
+ plotmeans(ncases/ncontrols ~ interaction(agegp , alcgp, sep =" "),
+ data=esoph,
+ connect=list(1:6,7:12,13:18,19:24),
+ barwidth=2,
+ barcol="dark blue",
+ col="dark blue",
+ add=TRUE)
+ grid()
+ abline(v=c(6.5, 12.5, 18.5), lty=2)
+
+
}
\author{Gregory R. Warnes \email{greg at warnes.net}}
More information about the R-gregmisc-commits
mailing list