[R] Bar plot with error bars

Daniel Nordlund res90sx5 at verizon.net
Mon Oct 22 23:45:02 CEST 2007


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Katherine Jones
> Sent: Monday, October 22, 2007 2:04 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Bar plot with error bars
> 
> Apologies if this has been asked before. I am having trouble
> understanding the R mailing list never mind R!
> 
> I am relatively new to R having migrated from Minitab and SPSS. I
> have managed to do some more complicated statistics such as
> hierarchical partitioning of variance on an 80,000 record dataset but
> have to admit that drawing a simple bar plot I could do by hand is
> proving extremely difficult!
> 
> I have Crawley's 'The R book' which is proving  a big help, but still
> does not provide me with all of the information I need.
> 
> What I want to do:-
> I have a small dataset, with 'rate' as the dependent variable (y axis
> variable) and two groups ('cat' and 'box') which I have calculated
> the mean and standard error for and would like to display as a bar
> plot. I would like to display the standard error for each group NOT a
> pooled standard error (i.e. error bars will be different heights on
> the two bars). In the Crawley book, he just repeats the same error
> bars across all groups, and I don't know how to specify the different
> error for each bar.
> 
> What I have managed to do so far:-
> -calculate mean and standard error
> -plots means with confidence intervals
> -plot means as bar plot but with no error bars or confidence intervals
> -everything except what I want to do!
> 
> I have learnt a lot about R but it is getting rather frustrating that
> I can do complex GLMs but cannot do a simple plot in 4 hours! I have
> migrated to R because I like the way it can do almost anything and
> because I'm trying to go almost completely freeware as everytime I
> move institution I run into trouble with getting software licenses
> which also tend to be expensive. However, I'm not the most computer
> literate person and have grown up with 'menus' and 'windows'.
> 
> Any help much appreciated as it will save me much time and frustration!
> 
> Dr. Katherine Jones
> Department of Biology,
> Carleton University
> 

Katherine,

You might take a look at the R Graph Gallery, specifically graph 54 by Marc Schwartz.  The code for the plot is there, which you should be able to modify.

The url is http://addictedtor.free.fr/graphiques/ .  You can click on browse, and page down to the graph. 

Hope this helpful,

Dan

Daniel Nordlund
Bothell, WA  USA



More information about the R-help mailing list