[R] Error bars.

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Mon Jun 17 23:25:47 CEST 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list