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:> > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Frank E Harrell Jr Prof. of Biostatistics & Statistics Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
There are also a plotmeans and plotCI functions in the gregmisc library which may do what is wanted.> -----Original Message----- > From: Michael Camann [mailto:mac24 at humboldt.edu] > Sent: Monday, June 17, 2002 1:27 PM > To: Rolf Turner > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] Error bars. > > > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._._._._._._._ >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-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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._