[R-gregmisc-users] SF.net SVN: r-gregmisc:[1911] trunk/gplots
Brought to you by:
warnes
From: <wa...@us...> - 2015-01-02 20:06:42
|
Revision: 1911 http://sourceforge.net/p/r-gregmisc/code/1911 Author: warnes Date: 2015-01-02 20:06:35 +0000 (Fri, 02 Jan 2015) Log Message: ----------- - plotmeans: Pass optional graphical arguments captured in '...' axis function used to draw the x axis. - plotmeans: Add an new argument 'text.n.label' to specify the text used for labelingthe number of elements in a group. Modified Paths: -------------- trunk/gplots/R/plotmeans.R trunk/gplots/man/plotmeans.Rd Modified: trunk/gplots/R/plotmeans.R =================================================================== --- trunk/gplots/R/plotmeans.R 2015-01-02 19:50:10 UTC (rev 1910) +++ trunk/gplots/R/plotmeans.R 2015-01-02 20:06:35 UTC (rev 1911) @@ -7,6 +7,7 @@ mean.labels=FALSE, ci.label=FALSE, n.label=TRUE, + text.n.label="N=", digits=getOption("digits"), col="black", barwidth=1, barcol="blue", @@ -78,7 +79,7 @@ xlab=xlab, ylab=ylab, labels=mean.labels, col=col, xlim=xlim, lwd=barwidth, barcol=barcol, minbar=minbar, maxbar=maxbar, ... ) if(invalid(xaxt) || xaxt!="n") - axis(1, at = 1:length(means), labels = legends) + axis(1, at = 1:length(means), labels = legends, ...) if(ci.label) { @@ -103,8 +104,12 @@ if(n.label) - text(x=1:length(means),y=par("usr")[3], - labels=paste("n=",ns,"\n",sep="")) + { + text(x=1:length(means), + y=par("usr")[3], + labels=paste(text.n.label, ns, "\n", sep="") + ) + } if(!invalid(connect) & !identical(connect,FALSE)) { @@ -120,6 +125,5 @@ lines(means, ..., lwd=lwd, col=ccol) } - } Modified: trunk/gplots/man/plotmeans.Rd =================================================================== --- trunk/gplots/man/plotmeans.Rd 2015-01-02 19:50:10 UTC (rev 1910) +++ trunk/gplots/man/plotmeans.Rd 2015-01-02 20:06:35 UTC (rev 1911) @@ -1,24 +1,17 @@ -% $Id$ - \name{plotmeans} \alias{plotmeans} \title{Plot Group Means and Confidence Intervals} \description{Plot group means and confidence intervals.} -%\synopsis{ \usage{ 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, lwd=par("lwd"), ...) + ci.label=FALSE, n.label=TRUE, text.n.label="n=", + digits=getOption("digits"), col="black", barwidth=1, + barcol="blue", connect=TRUE, ccol= + col, legends=names(means), xaxt, use.t=TRUE, + lwd=par("lwd"), ...) } -% -%\usage{ -% plotmeans( outcome ~ treatment) -%} - \arguments{ \item{formula}{symbolic expression specifying the outcome (continuous) and grouping variable (factor). See lm() for details.} @@ -42,12 +35,12 @@ \item{minbar}{minumum allowed value for bar ends. If specified, values smaller than \code{minbar} will be replaced with - \code{minbar}. } - + \code{minbar}. } + \item{maxbar}{maximum allowed value for bar ends. If specified, values larger than \code{maxbar} will be replaced with \code{maxbar}. } - + \item{xlab}{x-axis label.} \item{ylab}{y-axis label.} @@ -63,6 +56,9 @@ \item{n.label}{ a logical value indicating whether text giving the number of observations in each group should should be added to the plot. } + \item{text.n.label}{Prefix text for labeling observation counts. + Defaults to "n=". } + \item{digits}{ number of significant digits to use when displaying mean or confidince limit values.} @@ -86,22 +82,22 @@ \item{xaxt}{A character which specifies the axis type. Specifying `"n"' causes an axis to be set up, but not plotted.} - + \item{use.t}{ a logical value indicating whether the t distribution should be used to compute confidence intervals. If \code{TRUE}, the default, a t distribution will the correct number of degrees of freedom for each group be used. If \code{FALSE}, the a normal distribution will be used.} - + \item{lwd}{Width of connecting lines } - + \item{\dots}{ optional plotting parameters. } } -%\details{ -% -% +%\details{ +% +% %} @@ -109,7 +105,7 @@ # show comparison with boxplot data(state) - plotmeans(state.area ~ state.region) + plotmeans(state.area ~ state.region) # show some color and mean labels plotmeans(state.area ~ state.region, @@ -121,12 +117,12 @@ ccol="red", pch=7 ) # more complicated example showing how to show an interaction - data(esoph) + 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 =" "), + plotmeans(ncases/ncontrols ~ interaction(agegp , alcgp, sep =" "), connect=list(1:6,7:12,13:18,19:24), barwidth=2, col="dark green", @@ -137,7 +133,7 @@ "Ile-et-Vilaine Esophageal Cancer Study") ) abline(v=c(6.5, 12.5, 18.5), lty=2) - + } \author{Gregory R. Warnes \email{gr...@wa...}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |