barplot with errorbars

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

barplot with errorbars

Lathouri, Maria
Dear all

I have six variables of the average metal concentrations

Var1 4.77
Var2 23.5
Var3 5.2
Var4 12.3
Var5 42.1
Var6 121.2

I want to plot them as a barplot with error bars. Could you help me?

Cheers
Maria

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: barplot with errorbars

Toby Marthews-3
If you google "barplot with error bars" you immediately find http://svitsrv25.epfl.ch/R-doc/library/prada/html/barploterrbar.html .
Toby.

________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Lathouri, Maria [[hidden email]]
Sent: 17 February 2011 16:00
To: [hidden email]
Subject: [R] barplot with errorbars

Dear all

I have six variables of the average metal concentrations

Var1 4.77
Var2 23.5
Var3 5.2
Var4 12.3
Var5 42.1
Var6 121.2

I want to plot them as a barplot with error bars. Could you help me?

Cheers
Maria

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: barplot with errorbars

Mohamed Lajnef
In reply to this post by Lathouri, Maria
Hi Maria,

Look at  barplot function

? barplot  for help

Regards
M
Le 17/02/11 17:00, Lathouri, Maria a écrit :

> Dear all
>
> I have six variables of the average metal concentrations
>
> Var1 4.77
> Var2 23.5
> Var3 5.2
> Var4 12.3
> Var5 42.1
> Var6 121.2
>
> I want to plot them as a barplot with error bars. Could you help me?
>
> Cheers
> Maria
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

--
####################################
Mohamed Lajnef,IE INSERM U955 eq 15#
Pôle de Psychiatrie   #
Hôpital CHENEVIER                  #
40, rue Mesly                      #
94010 CRETEIL Cedex FRANCE         #
[hidden email]           #
tel : 01 49 81 31 31 (poste 18467) #
Sec : 01 49 81 32 90               #
fax : 01 49 81 30 99               #
####################################



        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: barplot with errorbars

Aldi Kraja-2
In reply to this post by Toby Marthews-3
Hi Toby and Maria,

I did a check on Toby's suggestion and it is not there:

R version 2.12.1 (2010-12-16)
 > ??barploterrbar
No help files found with alias or concept or title matching
'barploterrbar' using fuzzy matching.

Also I went to the following location which does not exist.
http://www.dkfz.de/abt0840/whuber

To Maria: here is a suggestion: to do the barplot with confidence
intervals / errorbars:

look at the following R news under www.r-project.org
"An introduction to using R's base graphics." (see following citation)
on page 4 you will find explanations and code how to build bars with se.

[62] Marc Schwartz. R Help Desk: An introduction to using R's base
graphics. /R News/, 3(2):2-6, October 2003. [ bib | http
<http://CRAN.R-project.org/doc/Rnews/> | .pdf
<http://CRAN.R-project.org/doc/Rnews/Rnews_2003-2.pdf> ]


HTH,

Aldi

On 2/17/2011 10:08 AM, Toby Marthews wrote:

> If you google "barplot with error bars" you immediately find http://svitsrv25.epfl.ch/R-doc/library/prada/html/barploterrbar.html .
> Toby.
>
> ________________________________________
> From: [hidden email] [[hidden email]] On Behalf Of Lathouri, Maria [[hidden email]]
> Sent: 17 February 2011 16:00
> To: [hidden email]
> Subject: [R] barplot with errorbars
>
> Dear all
>
> I have six variables of the average metal concentrations
>
> Var1 4.77
> Var2 23.5
> Var3 5.2
> Var4 12.3
> Var5 42.1
> Var6 121.2
>
> I want to plot them as a barplot with error bars. Could you help me?
>
> Cheers
> Maria
>
>
>

--



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: barplot with errorbars

William Revelle
As the FAQ
(http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-put-error-bars-or-confidence-bands-on-my-plot_003)
says,
there are about 5 different packages that will draw error bars.



At 2:38 PM -0600 2/17/11, Aldi Kraja wrote:

>Hi Toby and Maria,
>
>I did a check on Toby's suggestion and it is not there:
>
>R version 2.12.1 (2010-12-16)
>  > ??barploterrbar
>No help files found with alias or concept or title matching
>'barploterrbar' using fuzzy matching.
>
>Also I went to the following location which does not exist.
>http://www.dkfz.de/abt0840/whuber
>
>To Maria: here is a suggestion: to do the barplot with confidence
>intervals / errorbars:
>
>look at the following R news under www.r-project.org
>"An introduction to using R's base graphics." (see following citation)
>on page 4 you will find explanations and code how to build bars with se.
>
>[62] Marc Schwartz. R Help Desk: An introduction to using R's base
>graphics. /R News/, 3(2):2-6, October 2003. [ bib | http
><http://CRAN.R-project.org/doc/Rnews/> | .pdf
><http://CRAN.R-project.org/doc/Rnews/Rnews_2003-2.pdf> ]
>
>
>HTH,
>
>Aldi
>
>On 2/17/2011 10:08 AM, Toby Marthews wrote:
>>  If you google "barplot with error bars" you immediately find
>>http://svitsrv25.epfl.ch/R-doc/library/prada/html/barploterrbar.html 
>>.
>>  Toby.
>>
>>  ________________________________________
>>  From: [hidden email] [[hidden email]]
>>On Behalf Of Lathouri, Maria [[hidden email]]
>>  Sent: 17 February 2011 16:00
>>  To: [hidden email]
>>  Subject: [R] barplot with errorbars
>>
>>  Dear all
>>
>>  I have six variables of the average metal concentrations
>>
>>  Var1 4.77
>>  Var2 23.5
>>  Var3 5.2
>>  Var4 12.3
>>  Var5 42.1
>>  Var6 121.2
>>
>>  I want to plot them as a barplot with error bars. Could you help me?
>>
>>  Cheers
>>  Maria
>>
>>
>>
>
>--
>
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: barplot with errorbars

Marc Schwartz-3
In reply to this post by Aldi Kraja-2
Aldi,

Thanks for the reference to the R News article. That seems like a lifetime ago...  :-)

As an exercise in learning to use R's base graphics and some of the concepts of manipulating and annotating base R plots, it is a decent intro.

That being said, unless pressured (eg. weapon pointing at cranium), I would never actually use that particular format (the barplots) today in presenting data. The same goes for the barplot2() function in the gplots CRAN package, which I wrote, but have literally not used in years. That function automates barplots and confidence interval plotting, amongst other enhancements (eg. log scaled axes), to the base barplot() function.

If I may, allow me to offer some additional comments to Maria.

First, note that barplots are best used to present discrete counts or perhaps percentages, not continuous data. The y axis (in the case of a vertical barplot) is intended to start at 0 to allow the appropriate perception of count/percentage based differences within or between groups, as represented by the heights of the bars.

The addition of confidence intervals to barplots, especially only the upper bound, which are also known as dynamite plots (http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots), are generally frowned upon these days, though there are communities that still prefer that format for count data.

For continuous data however, point plots with confidence intervals are much preferred. Other alternatives include boxplots and violin plots, if one is wanting to visually present more information on the distribution of a continuous variable between groups, beyond point estimates for the means and CIs.

Frank has a nice intro document on statistical graphics here:

  http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatGraphCourse/graphscourse.pdf

that you might want to review.

I would urge Maria to consider alternatives to using a barplot to present this data. There are various custom functions to aid with that (searching the list archives using rseek.org should yield good results) and the ?arrows and ?segments functions typically serve as the basis for drawing the CIs around the points representing the means.

HTH,

Marc Schwartz



On Feb 17, 2011, at 2:38 PM, Aldi Kraja wrote:

> Hi Toby and Maria,
>
> I did a check on Toby's suggestion and it is not there:
>
> R version 2.12.1 (2010-12-16)
>> ??barploterrbar
> No help files found with alias or concept or title matching
> 'barploterrbar' using fuzzy matching.
>
> Also I went to the following location which does not exist.
> http://www.dkfz.de/abt0840/whuber
>
> To Maria: here is a suggestion: to do the barplot with confidence
> intervals / errorbars:
>
> look at the following R news under www.r-project.org
> "An introduction to using R's base graphics." (see following citation)
> on page 4 you will find explanations and code how to build bars with se.
>
> [62] Marc Schwartz. R Help Desk: An introduction to using R's base
> graphics. /R News/, 3(2):2-6, October 2003. [ bib | http
> <http://CRAN.R-project.org/doc/Rnews/> | .pdf
> <http://CRAN.R-project.org/doc/Rnews/Rnews_2003-2.pdf> ]
>
>
> HTH,
>
> Aldi
>
> On 2/17/2011 10:08 AM, Toby Marthews wrote:
>> If you google "barplot with error bars" you immediately find http://svitsrv25.epfl.ch/R-doc/library/prada/html/barploterrbar.html .
>> Toby.
>>
>> ________________________________________
>> From: [hidden email] [[hidden email]] On Behalf Of Lathouri, Maria [[hidden email]]
>> Sent: 17 February 2011 16:00
>> To: [hidden email]
>> Subject: [R] barplot with errorbars
>>
>> Dear all
>>
>> I have six variables of the average metal concentrations
>>
>> Var1 4.77
>> Var2 23.5
>> Var3 5.2
>> Var4 12.3
>> Var5 42.1
>> Var6 121.2
>>
>> I want to plot them as a barplot with error bars. Could you help me?
>>
>> Cheers
>> Maria

______________________________________________
[hidden email] 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.