[Rd] Suggestion: barplot function
Marc Schwartz
marc_schwartz at me.com
Fri Feb 3 17:05:41 CET 2017
> 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]]
More information about the R-devel
mailing list