# Re: [R] bars with sd

From: Sean Davis (sdavis2@mail.nih.gov)
Date: Sat 22 May 2004 - 01:22:14 EST

```Message-id: <BCD396E6.838E%sdavis2@mail.nih.gov>

```

Matteo,

I think that in the gregmisc package, there is barplot2 which is an
enhancement to barplot that allows error bars. You might look into that
option, also.

Sean

On 5/21/04 11:15 AM, "Spencer Graves" <spencer.graves@pdf.com> wrote:

>> DF <- data.frame(mean=c(1.25, 2.65, 3.45), sd=c(.35, .65, .5),
> + row.names=letters[1:3])
>> plot(1:3, DF\$mean, ylim=range(DF\$mean-2*DF\$sd, DF\$mean+2*DF\$sd))
>> segments(1:3, DF\$mean-2*DF\$sd, 1:3, DF\$mean+2*DF\$sd)
>
> hope this helps. spencer graves
>
> Matteo Vidali wrote:
>
>> I need some help for a curious question of a friend of mine.
>> She usually does some experiments (3-5 repeats for each exp) and then she
>> calculates mean and standard deviation.
>> In microsoft excel she writes something like the following
>>
>> sample mean sd
>> a 1.25 0.35
>> b 2.65 0.65
>> c 3.45 0.50
>>
>> She can do a vertical barplot graph just giving mean value and specifying
>> the standard deviation value for each bar in the graph.
>>
>> My friend wants to know if it is possible to do the same with R. She has
>> tried also with Open Office and seen that in that program you can plot mean
>> values as bars but it is not possible to specify a different sd for each
>> bar 'cause the program, if you ask to put the standard deviation, calculates
>> a common sd using the mean values.
>> I was not able to give her an answer for the barplot function in R. I have
>> just said to her that it is likely due to the fact that using a barplot
>> graph to plot mean and standard deviation values it is non a good practice,
>> since the height (or the area) of bars should represent frequency and that
>> putting a standard deviation in that way it is at least quite confusing for
>> the reader to interpret the graph. Some scientific journal revisors
>> discourage this practice. She should instead use a boxplot or just plotting
>> the different repetition values for each sample as points and add a linea
>> indicating the mean.
>> But if this is correct why in some programs like open office you can plot
>> bars with a common standard deviation???? when will you need this last type
>> of graph?
>>
>> any suggestion? any help?
>> Matteo
>>
>> ______________________________________________
>> R-help@stat.math.ethz.ch mailing list
>> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>
>>
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help