[R] Multiple error bar plots
Manuel Morales
Manuel.A.Morales at williams.edu
Fri Mar 24 21:36:24 CET 2006
Hi Young-Jin,
On Fri, 2006-03-24 at 10:42 -0500, Young-Jin Lee wrote:
> Dear R-lister
>
> I have a question about how to create multiple error bar plots.
> I found that I can use an "errbar" function from Hmisc package to create one
> error bar plot in which there are multiple data points (x, y) with the error
> bars. Thus, I know that I can get "one" error bar plot which consists of
> many data points. However, I did not find a way to put "multiple" error bar
> plots into one.
I wrote my own package to deal with exactly this scenario. You can
download it from:
http://mutualism.williams.edu/sciplot/
The relevant function is "bargraph.CI". BTW, I did this mostly to learn
about writing packages in R, but it may be helpful to you.
> In other words, my data looks like this:
> X1 (group index), Y11 (measurement), error of Y11 (error in measurement)
> X2, Y21, error of Y21
> ...
> Xn, Yn1, error of Yn1 // End of the first set of measurements
>
> X1, Y12, error of Y12,
> X2, Y22, error of Y22,
> ...
> Xn, Yn2, error of Yn2 // End of the second set of measurements
>
> X1, Y13, error of Y13,
> X2, Y23, error of Y23,
> ...
> Xn, Yn3, error of Yn3 // end of the third set of measurements
BTW, you'll need to format you're data like:
X Y_i Measurement
1 1 1.1
1 1 1.2
...
2 1 1.2
2 1 1.5
...
3 1 1.3
3 1 1.1
...
1 2 1.1
...
In other words, you need all the measurements for each group+measurement
category rather than means and errors because the function calculates
the mean and CI for you.
HTH
Manuel
More information about the R-help
mailing list