[R-gregmisc-users] SF.net SVN: r-gregmisc:[1899] trunk/gplots
Brought to you by:
warnes
From: <wa...@us...> - 2014-12-01 22:52:57
|
Revision: 1899 http://sourceforge.net/p/r-gregmisc/code/1899 Author: warnes Date: 2014-12-01 22:52:47 +0000 (Mon, 01 Dec 2014) Log Message: ----------- Convert bandplot to S3-method dispatch and add method for class formula. Modified Paths: -------------- trunk/gplots/DESCRIPTION trunk/gplots/R/bandplot.R trunk/gplots/man/bandplot.Rd Modified: trunk/gplots/DESCRIPTION =================================================================== --- trunk/gplots/DESCRIPTION 2014-12-01 22:51:46 UTC (rev 1898) +++ trunk/gplots/DESCRIPTION 2014-12-01 22:52:47 UTC (rev 1899) @@ -4,8 +4,8 @@ Depends: R (>= 3.0) Imports: gtools, gdata, stats, caTools, KernSmooth Suggests: grid, MASS -Version: 2.14.1 -Date: 2014-06-30 +Version: 2.15.0 +Date: 2014-12-01 Author: Gregory R. Warnes, Ben Bolker, Lodewijk Bonebakker, Robert Gentleman, Wolfgang Huber Andy Liaw, Thomas Lumley, Martin Maechler, Arni Magnusson, Steffen Moeller, Marc Schwartz, Bill Modified: trunk/gplots/R/bandplot.R =================================================================== --- trunk/gplots/R/bandplot.R 2014-12-01 22:51:46 UTC (rev 1898) +++ trunk/gplots/R/bandplot.R 2014-12-01 22:52:47 UTC (rev 1899) @@ -1,6 +1,9 @@ # $Id$ -bandplot <- function(x,y, +bandplot <- function(x, ...) + UseMethod("bandplot") + +bandplot.default <- function(x, y, ..., add=FALSE, sd=c(-2:2), @@ -53,3 +56,70 @@ } } + + +bandplot.formula <- function(x, + data=parent.frame(), + subset, + na.action, + xlab=NULL, + ylab=NULL, + ..., + add=FALSE, + sd=c(-2:2), + sd.col=c("magenta","blue","red", + "blue","magenta"), + sd.lwd=c(2,2,3,2,2), + sd.lty=c(2,1,1,1,2), + method="frac", width=1/5, + n=50 + ) + { + if (missing(x) || (length(x) != 3)) + stop("x missing or incorrect") + if (missing(na.action)) + na.action <- getOption("na.action") + m <- match.call(expand.dots = FALSE) + if (is.matrix(eval(m$data, parent.frame()))) + m$data <- as.data.frame(data) + m$formula <- m$x + m$... <- m$x <- m$f <- m$iter <- m$delta <- NULL + m$xlab <- m$ylab <- m$add <- m$sd <- NULL + m$sd.col <- m$sd.lwd <- m$sd.lty <- NULL + m$method <- m$width <- m$n <- NULL + + m[[1]] <- as.name("model.frame") + mf <- eval(m, parent.frame()) + response <- attr(attr(mf, "terms"), "response") + + sx <- substitute(x) + + if (is.null(xlab)) { + if (mode(x) != "name") + xlab <- deparse(sx[[3L]]) + else + xlab <- "x" + } + + if (is.null(ylab)) { + if (mode(x) != "name") + ylab <- deparse(sx[[2L]]) + else + ylab <- "y" + } + + bandplot.default(x=mf[[-response]], + y=mf[[response]], + ..., + xlab=xlab, + ylab=ylab, + add=add, + sd=sd, + sd.col=sd.col, + sd.lwd=sd.lwd, + sd.lty=sd.lty, + method=method, + width=width, + n=n + ) + } Modified: trunk/gplots/man/bandplot.Rd =================================================================== --- trunk/gplots/man/bandplot.Rd 2014-12-01 22:51:46 UTC (rev 1898) +++ trunk/gplots/man/bandplot.Rd 2014-12-01 22:52:47 UTC (rev 1899) @@ -1,40 +1,32 @@ -% $Id$ -% -% $Log$ -% Revision 1.7 2005/12/01 16:46:52 nj7w -% Updated Greg's email address -% -% Revision 1.6 2005/06/09 14:20:28 nj7w -% Updating the version number, and various help files to synchronize splitting of gregmisc bundle in 4 individual components. -% -% Revision 1.1.1.1 2005/05/25 22:15:30 nj7w -% Initial submission as an individual package -% -% Revision 1.5 2003/11/19 14:52:32 warnes -% -% Remove extranious NULL that confused R CMD check. -% -% Revision 1.4 2002/09/23 13:59:30 warnes -% - Modified all files to include CVS Id and Log tags. -% -% - \name{bandplot} \alias{bandplot} +\alias{bandplot.formula} +\alias{bandplot.default} \title{Plot x-y Points with Locally Smoothed Mean and Standard Deviation} \description{ - Plot x-y Points with lines showing the locally smoothed mean and - standard deviation. - } + Plot x-y points with curves for locally smoothed mean and standard deviation. +} \usage{ - bandplot(x, y, ..., add = FALSE, sd = c(-2:2), +bandplot(x,...) +\method{bandplot}{formula}(x, data=parent.frame(), subset, na.action, ..., + xlab=NULL, ylab=NULL, add = FALSE, sd = c(-2:2), sd.col=c("magenta", "blue", "red", "blue", "magenta"), sd.lwd=c(2, 2, 3, 2, 2), sd.lty=c(2, 1, 1, 1, 2), - method = "frac", width = 1/5, n=50) + method = "frac", width = 1/5, n=50) +\method{bandplot}{default}(x, y, ..., add = FALSE, sd = c(-2:2), + sd.col=c("magenta", "blue", "red", "blue", "magenta"), + sd.lwd=c(2, 2, 3, 2, 2), sd.lty=c(2, 1, 1, 1, 2), + method = "frac", width = 1/5, n=50) } \arguments{ - \item{x}{numeric vector of x locations} - \item{y}{numeric vector of x locations} + \item{x}{either formula providing a single dependent variable (y) and + an single independent variable (x) to use as coordinates in the + scatter plot or a numeric vector of x locations} + \item{y}{numeric vector of y locations} + \item{data}{a data.frame (or list) from which the variables in `formula' + should be taken.} + \item{subset}{ an optional vector specifying a subset of observations to be + used in the fitting process. } \item{\dots}{Additional plotting parameters. } \item{add}{ Boolean indicating whether the local mean and standard deviation lines should be added to an existing plot. Defaults to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |