Skip to content

Error bars.

3 messages · Rolf Turner, Frank E Harrell Jr, Michael Camann

#
There was an inquiry on this list recently about plotting some simple
error bars on a graph.  Now Splus has a function (error.bar ---
originally written by Sue Clancy of DMS, CSIRO, I believe) to do this
job virtually at the touch of a key.  (Well a few keys. :-) )  The
error.bar function is written completely in raw S --- no calls to
``.Internal'' or anything like that.  So it would be trivial to port
over to R.

My question is:  Is doing so legal?  Moral?  (Given that Splus is
proprietary, and error.bar is a ``built-in'' part of that package,
and not something out of statlib, or like that.)

				cheers,

					Rolf Turner
					rolf at math.unb.ca
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
The errbar function in the Hmisc library for R/S+ is not as comprehensive as the S+ error.bar function but it does most of what's needed (for vertical bars anyway).  It was originally written by Geyer in 1991.  There is another version of it ('error') which is a function internal to xYplot when lattice/grid is in effect.  -Frank Harrell

On Mon, 17 Jun 2002 11:11:39 -0300 (ADT)
Rolf Turner <rolf at math.unb.ca> wrote:

            

  
    
#
Rolf et al.--

Here's a simple error bar function in R.

# produce vertical error bars on a plot-- aliased vbars in anticipation
# of the day when I need hbars to plot horizontal error bars....
#
# error bars originate at (x, y0) and radiate to y0 + y1 and y0 - y2
#
# example (adds +- 1.0 SE to a barplot of means for data vector x):
#
# y.mean <- mean(x)				# mean
# y.se <- sqrt(var(x,na.rm=TRUE)/length(x))	# std err
# z <- barplot(y.mean,plot=FALSE)		# location of bars
# barplot(y.mean,...)				# the real plot
# ebars(z,y.mean,y.mean+y.se,y.mean-y.se)	# add error bars


ebars <- vbars <- function (x, y0, y1, y2)
{
  for(i in 1:length(x))
  {
    if(y0[i]!=0 & !is.na(y0[i]) & y1[i]!=0 & !is.na(y1[i]) &
      (y0[i]!=y2[i]))
    {
      arrows (x[i], y0[i], x[i], y1[i], angle=90, length=0.05)
    }
    if(y0[i]!=0 & !is.na(y0[i]) & y2[i]!=0 & !is.na(y2[i]) &
      (y0[i]!=y2[i]))
    {
      arrows (x[i], y0[i],  x[i], y2[i],  angle=90, length=0.05)
    }
  }
}

--Mike C.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael A. Camann                                  Voice: 707-826-3676
Associate Professor of Zoology                       Fax: 707-826-3201
Institute for Forest Canopy Research     Email: mac24 at axe.humboldt.edu
Department of Biology                            ifcr at axe.humboldt.edu
Humboldt State University
Arcata, CA 95521

                 URL:http://www.humboldt.edu/~mac24/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._