Hello developers folks! First, congratulations for the wonderful work with R. For science, barplots with error bars are very important. We were wondering that is so easy to use the boxplot function: boxplot(Spores~treatment, col=treatment_colors) But there is no such function for barplots with standard deviation or standard error. It becomes a "journey" to plot a simple graph (e.g. https://www.r-bloggers.com/building-barplots-with-error-bars/). The same way that is easy to use the boxplot function, do you think it is possible to upgrade the barplot function: i.e.: barplot(Spores~treatment, error.bar=standard_error, col=treatment_colors) Thank you so much! Daniel, FU-Berlin
> On Jan 27, 2017, at 8:30 AM, danielrenato at lycos.com wrote: > > Hello developers folks! > > First, congratulations for the wonderful work with R. > > For science, barplots with error bars are very important. We were wondering that is so easy to use the boxplot function: > > boxplot(Spores~treatment, col=treatment_colors) > > But there is no such function for barplots with standard deviation or standard error. It becomes a "journey" to plot a simple graph (e.g. https://www.r-bloggers.com/building-barplots-with-error-bars/). > > The same way that is easy to use the boxplot function, do you think it is possible to upgrade the barplot function: i.e.: barplot(Spores~treatment, error.bar=standard_error, col=treatment_colors) > > Thank you so much! > Daniel, FU-BerlinHi, With the caveat that I do not speak on behalf of R Core: Boxplots are specifically designed to include "whiskers" (NOT error bars) that aid to visually describe the distribution of continuous data. The whiskers do not represent standard deviations (SDs). Thus, that the boxplot() function contains the code to draw the whiskers automatically is not relevant to barplot(). Barplots are best used to visually present tabulations of categorical data (e.g. counts or percentages), in which case, the "error" bars would typically represent binomial or similar confidence intervals. Even there, many will advocate that dotplots be used instead as a better presentation format, as barplots, much like pie charts, have a high "ink to data" ratio. Barplots should not really be used to present continuous data (e.g. means and SDs). You will find a great deal of disagreement with your premise that barplots with error bars are very important to science. If you do a Google search for "Dynamite Plot", especially where only the upper error bar is included, you will find a variety of critical discussions on that point, such as: http://biostat.mc.vanderbilt.edu/wiki/pub/Main/TatsukiRcode/Poster3.pdf <http://biostat.mc.vanderbilt.edu/wiki/pub/Main/TatsukiRcode/Poster3.pdf> You pointed to one example of how easy it is to actually add error bars to a barplot in R, and that approach, of incrementally building plots using multiple functions, is an integral part of R's philosophy. There is also an example in ?barplot. Generally, R's default approaches to most analyses are extremely well reasoned. Thus, if you don't see something in a function by default, there is generally strong logic behind what is being done, or as in this case, not being done. If you wanted to, it would be a reasonable exercise for you to create your own plotting function that wraps barplot() and either segments() or arrows() in a single function call, where you can pass arguments that contain the values for the various components and draw the plot as you desire. That is how a lot of R code is created. There are other graphic functions in R packages, such as ggplot2 (https://www.r-bloggers.com/using-r-barplot-with-ggplot2/ <https://www.r-bloggers.com/using-r-barplot-with-ggplot2/>) and others on CRAN that offer methods to add error bars to barplots that others have created if you wanted to research those. As a result of all of the above, I am not sure that, after all these years, error bars would be added to barplot() as a standard feature. Regards, Marc Schwartz [[alternative HTML version deleted]]
On 1/27/2017 8:30 AM, danielrenato at lycos.com wrote:> Hello developers folks! > > First, congratulations for the wonderful work with R. > > For science, barplots with error bars are very important. We were > wondering that is so easy to use the boxplot function: > > boxplot(Spores~treatment, col=treatment_colors) > > But there is no such function for barplots with standard deviation or > standard error. It becomes a "journey" to plot a simple graph (e.g. > https://www.r-bloggers.com/building-barplots-with-error-bars/). > > The same way that is easy to use the boxplot function, do you think it > is possible to upgrade the barplot function: i.e.: > barplot(Spores~treatment, error.bar=standard_error, col=treatment_colors)Marc may not speak for R Core, but he certainly has summarized what has been an apparent consensus attitude to barplot() and confidence bars in this community over the last decade. Further, he is probably right about no changes after this many years. I might mention that if you want a close cousin to barplot() that does what you want with base graphics (from the drawing mechanics point of view) see the barplot2() function in the gplots package. You provide your own bar lengths. Regardless of their merits, barplots are a common graphing mechanism used by my scientific colleagues to convey their data, and I don't see that changing any time soon. The one thing that is even less forgivable than dynamite plots is bars with no dispersion indication at all. Too bad barplot2() isn't the default.> > Thank you so much! > Daniel, FU-Berlin > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- -- Robert W. Baer, Ph.D. Professor of Physiology Kirksville College of Osteopathic Medicine A T Still University of Health Sciences 800 W. Jefferson St Kirksville, MO 63501 660-626-2321 Department 660-626-2965 FAX
> On Feb 3, 2017, at 8:23 AM, Robert Baer <rbaer at atsu.edu> wrote: > > > On 1/27/2017 8:30 AM, danielrenato at lycos.com wrote: >> Hello developers folks! >> >> First, congratulations for the wonderful work with R. >> >> For science, barplots with error bars are very important. We were wondering that is so easy to use the boxplot function: >> >> boxplot(Spores~treatment, col=treatment_colors) >> >> But there is no such function for barplots with standard deviation or standard error. It becomes a "journey" to plot a simple graph (e.g. https://www.r-bloggers.com/building-barplots-with-error-bars/). >> >> The same way that is easy to use the boxplot function, do you think it is possible to upgrade the barplot function: i.e.: barplot(Spores~treatment, error.bar=standard_error, col=treatment_colors) > Marc may not speak for R Core, but he certainly has summarized what has been an apparent consensus attitude to barplot() and confidence bars in this community over the last decade. Further, he is probably right about no changes after this many years. > > I might mention that if you want a close cousin to barplot() that does what you want with base graphics (from the drawing mechanics point of view) see the barplot2() function in the gplots package. You provide your own bar lengths. Regardless of their merits, barplots are a common graphing mechanism used by my scientific colleagues to convey their data, and I don't see that changing any time soon. The one thing that is even less forgivable than dynamite plots is bars with no dispersion indication at all. Too bad barplot2() isn't the default.Hi, Since Robert has kindly raised the barplot2() function, in the interest of full disclosure, as the original author of that function, my prior comments may seem contradictory. I originally wrote the barplot2() function back in 2002 (https://stat.ethz.ch/pipermail/r-devel/2002-September/025092.html <https://stat.ethz.ch/pipermail/r-devel/2002-September/025092.html>), based upon my usage patterns at the time. It included the ability to use log scaled axes (later added to base R's barplot()), binomial confidence intervals and some other features, building directly on the default barplot() function code in base R for compatibility. It was an early attempt back then, to give back to the community based upon some requests at the time. Greg Warnes was subsequently kind enough to offer to include it in the gplots package on CRAN. That being said, because of the issues that I raised in my prior reply, which also reflect my own evolution in thinking in the many years since, I have not used the barplot2() function nor modified/updated the code in any way in well over 10 years. In fact, in general, I find that my clients in the clinical domains that I work in, have also come to see less value in their use, in deference to other presentation formats and I rarely use them in my analyses. As I noted in my prior reply, where I see them still commonly used tends to be for tabulations/counts for things like monthly/quarterly clinical trial enrollment trends, etc. In either case, Robert rightly raises the point that, despite the criticisms, they are still widely used as change can be slow to manifest. Thus, there are options to create such plots where desired, using barplot2(), the ggplot2 package and other functions in various CRAN packages. Or as I noted, if you don't want to install a package just for the sake of this one feature, it is easy to create them with a few function calls like segments() or arrows() over the default barplot. Regards, Marc>> >> Thank you so much! >> Daniel, FU-Berlin >> >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > -- > > > -- > Robert W. Baer, Ph.D. > Professor of Physiology > Kirksville College of Osteopathic Medicine > A T Still University of Health Sciences > 800 W. Jefferson St > Kirksville, MO 63501 > 660-626-2321 Department > 660-626-2965 FAX > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel[[alternative HTML version deleted]]
Hi Marc and Robert, Thank you so much for the answer! I agree with both of you, specially with Robert "barplots are a common graphing mechanism used by my scientific colleagues to convey their data, and I don't see that changing any time soon... The one thing that is even less forgivable ... is bars with no dispersion indication at all." (what barplot() allows). Nowadays there are dozens of new papers everyday, and to make it easier/faster to the readers, it is very common (in biological sciences) authors show the data using bar-plots (that represent mean of treatments and the standard deviation - and usually with letters representing if the treatments are different, or not, using some statistical test). Maybe it is not a great way, but it is in an intuitive way largely used in natural sciences that make it easier to the readers. And it is accepted in most of the scientific journals, including Science, Nature, PNAS, Frontiers... I agree with Marc that it is nice that R is flexible, so people can go around even that it is not the default. However it is a difficult task for most of the users (e.g.from biological sciences). Thank you Marc and Robert, Cheers, Daniel On 2017-02-03 14:23, Robert Baer wrote:> On 1/27/2017 8:30 AM, danielrenato at lycos.com wrote: > >> Hello developers folks! >> >> First, congratulations for the wonderful work with R. >> >> For science, barplots with error bars are very important. We were wondering that is so easy to use the boxplot function: >> >> boxplot(Spores~treatment, col=treatment_colors) >> >> But there is no such function for barplots with standard deviation or standard error. It becomes a "journey" to plot a simple graph (e.g. https://www.r-bloggers.com/building-barplots-with-error-bars/). >> >> The same way that is easy to use the boxplot function, do you think it is possible to upgrade the barplot function: i.e.: barplot(Spores~treatment, error.bar=standard_error, col=treatment_colors) > Marc may not speak for R Core, but he certainly has summarized what has been an apparent consensus attitude to barplot() and confidence bars in this community over the last decade. Further, he is probably right about no changes after this many years. > > I might mention that if you want a close cousin to barplot() that does what you want with base graphics (from the drawing mechanics point of view) see the barplot2() function in the gplots package. You provide your own bar lengths. Regardless of their merits, barplots are a common graphing mechanism used by my scientific colleagues to convey their data, and I don't see that changing any time soon. The one thing that is even less forgivable than dynamite plots is bars with no dispersion indication at all. Too bad barplot2() isn't the default. > >> Thank you so much! >> Daniel, FU-Berlin >> >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel[[alternative HTML version deleted]]