From bolker@zoo.ufl.edu  Mon May 28 06:39:57 2001
From: bolker@zoo.ufl.edu (bolker@zoo.ufl.edu)
Date: Mon, 28 May 2001 01:39:57 -0400 (EDT)
Subject: [Rd] New Package: gregmisc
In-Reply-To: <5429125E11E4D411AF7300805FE603A8014CEAFC@groexmbcr02.pfizer.com>
Message-ID: <Pine.LNX.4.30.0105280132420.5852-100000@bolker.zoo.ufl.edu>


   Do you have the latest version of plotCI?  (attached below, I didn't
send it as an attachment for the sake of R-devel)  It uses arrows()
instead of segments(), which simplifies the code a bit and incidentally
makes it work with logarithmic axes as well (since the sizes of the bar
ends are specified in absolute rather than user units).

  Should this code be the first entry in the "miscellaneous code"
repository at CRAN that was discussed a while back?

  By the way, something occurred to me ... my "miscellaneous packages"
function (which I haven't made available to CRAN yet, although I probably
will eventually) is called "bbmisc".  Yours is called "gregmisc".  Would
it make any sense to standardize these on "<lastname>misc" or
"<first_initial><lastname>misc" (bolkermisc, bbolkermisc) to avoid
confusion once we have a whole bunch of these packages?

  Also by the way, congratulations for actually getting around to posting
your miscellaneous functions to CRAN!  I hope to do as well.

  Ben Bolker

plotCI <- function (x, y = NULL, uiw, liw = uiw, aui=NULL, ali=aui,
                    err="y", ylim=NULL, xlim=NULL, sfrac = 0.01, gap=0, add=FALSE,
                    col=par("col"), lwd=par("lwd"), slty=par("lty"), xlab=NULL,
                    ylab=NULL, main="", pt.bg = NA, scol=col,
                    axes=TRUE, ...)  {
# from Bill Venables, R-list
  if (is.list(x)) {
    y <- x$y
    x <- x$x
  }
  if (is.null(y)) {
    if (is.null(x))
      stop("both x and y NULL")
    y <- as.numeric(x)
    x <- seq(along = x)
  }
  if (missing(xlab)) xlab <- deparse(substitute(x))
  if (missing(ylab)) ylab <- deparse(substitute(y))
  if (missing(uiw)) {  ## absolute limits
    ui <- aui
    li <- ali
  }
  else {  ## relative limits
    if (err=="y") z <- y else z <- x
    ui <- z + uiw
    li <- z - liw
  }
  if (err=="y" & is.null(ylim))
    ylim <- range(c(y, ui, li), na.rm=TRUE)
  else
    if (err=="x" & is.null(xlim))
      xlim <- range(c(x, ui, li), na.rm=TRUE)
  if (!add)
    plot(x, y, ylim = ylim, xlim = xlim, col=col, lwd=lwd, xlab=xlab, ylab=ylab,
         main=main, type="n", axes=axes, ...)
  if (gap==TRUE) gap <- 0.01  ## default gap size
  ul <- c(li, ui)
  if (err=="y") {
    gap <- rep(gap,length(x))*diff(par("usr")[3:4])
    smidge <- par("fin")[1] * sfrac
    arrows(x , li, x, pmax(y-gap,li), col=col, lwd=lwd, lty=slty, angle=90, length=smidge, code=1)
    arrows(x , ui, x, pmin(y+gap,ui), col=col, lwd=lwd, lty=slty, angle=90, length=smidge, code=1)
  }
  else if (err=="x") {
    gap <- rep(gap,length(x))*diff(par("usr")[1:2])
    smidge <- par("fin")[2] * sfrac
    arrows(li, y, pmax(x-gap,li), y, col=col, lwd=lwd, lty=slty, angle=90, length=smidge, code=1)
    arrows(ui, y, pmin(x+gap,ui), y, col=col, lwd=lwd, lty=slty, angle=90, length=smidge, code=1)
  }
  ## _now_ draw the points (in case we want to have "bg" set for points)
  points(x, y, col=col, lwd=lwd, bg=pt.bg, ...)
  invisible(list(x = x, y = y))
}

On Thu, 24 May 2001, Warnes, Gregory R wrote:

> I've thrown a couple of useful functions into a new package "gregmisc" and
> uploaded them to ftp://ftp.ci.tuwien.ac.at/incoming/gregmisc_0.1.1.tgz
>
> Here's DESCRIPTION:
>
> 	Package: gregmisc
> 	Description: Misc Functions written/maintained by Gregory R. Warnes
> 	Title: Greg's Miscellaneous Functions
> 	Version: 0.1
> 	Date: 2001/05/24
> 	Depends: R
> 	Maintainer: Gregory R. Warnes <Gregory_R_Warnes@groton.pfizer.com>
>
> 	Author: Gregory R. Warnes.  Includes code provided by William
> Venables
> 	        and Ben Bolker.
> 	License: GPL (version 2 or later)
>
> and INDEX:
>
> 	boxplot.n                Produce a Boxplot Annotated with the Number
> of
> 	                         Observations
> 	ci                       Compute Confidence Intervals
> 	plotCI                   Plot Error Bars
> 	plotmeans                Plot Group Means and Confidence Intervals
>
>
> I'm perfectly happy for these functions to get incorporated into other
> packages.  Feel free to email comments/criticisms/whatever.
>
> -Greg
>
>
>
>
> LEGAL NOTICE
> Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
318 Carr Hall                                bolker@zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] New Package: gregmisc
bolker@zoo.ufl.edu