Re: [R] Constructing bar charts with standard error bars

From: Frank E Harrell Jr <f.harrell_at_vanderbilt.edu>
Date: Wed, 25 Jul 2007 11:21:56 -0500

John Zabroski wrote:
> I am new to R.
>
> I want to graph group data using a "Traditional Bar Chart with Standard
> Error Bar", like the kind shown here:
> http://samiam.colorado.edu/~mcclella/ftep/twoGroups/twoGroupGraphs.html

There are severe problems with dynamite plots such as these. See http://biostat.mc.vanderbilt.edu/DynamitePlots for a list of problems and solutions.

Frank

>
> Is there a simple way to do this?
>
> So far, I have only figured out how to plot the bars using barplot.
>
> testdata <- scan(, list(group=0,xbar=0,se=0))
> 400 0.36038 0.02154
> 200 0.35927 0.02167
> 100 0.35925 0.02341
> 50 0.35712 0.01968
> 25 0.35396 0.01931
>
> barplot(testdata$xbar, names.arg=as.character(testdata$group), main="a=4.0",
> xlab="Group", ylab="xbar")
> xvalues <- c(0.7, 1.9, 3.1, 4.3, 5.5)
> arrows(xvalues, testdata$xbar, xvalues, testdata$xbar+testdata$se, length=
> 0.4, angle=90, code=3)
>
>
> The best clue I have so far is Rtips #5.9:
> http://pj.freefaculty.org/R/Rtips.html#5.9 which is what I based my present
> solution off of.
>
> However, I do not understand how this works. It seems like there is no
> concrete way to determine the arrow drawing parameters x0 and x1 for a
> barplot. Moreover, the bars seem to be "cut off".
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 25 Jul 2007 - 16:34:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 25 Jul 2007 - 17:33:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.