[R] Lattice barchart with error bars
dwinsemius at comcast.net
Fri Jul 5 20:28:35 CEST 2013
On Jul 5, 2013, at 11:15 AM, Shaun Jackman wrote:
> Hi Bert, Dennis,
> I'll agree that using a barchart was a poor choice. I was in fact using a
> notched bwplot to show the median and confidence interval of the median. In
> this case it's the median and confidence interval that I want to highlight,
> and I find that the visual noise of the box and whiskers is detracting from
> the focus, and those wee notches are not much to focus on. So, I'd like to
> draw a stripplot with error bars, preferably in Lattice. Let's call this a
> TIE fighter plot. Any suggestions?
I like the TIE fighter label. Try this:
segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male,
data = subset(USCancerRates, state == "Washington"),
draw.bands = FALSE, centers = rate.male,
segments.fun = panel.arrows, ends = "both",
angle = 90, length = 1, unit = "mm")
It's what Sarkar has recommended in the past when this request has been posted.
> On 4 July 2013 18:00, Dennis Murphy <djmuser at gmail.com> wrote:
>> If you consult the lattice package help, you'll discover there is no
>> panel_errorbar() function, which would imply the package developers
>> have a distaste for that type of graphic. If you fish around the
>> R-help archives, though, you might be able to find someone who wrote a
>> function to do error bars in lattice. (Use a searchable archive such
>> as Nabble to hunt for it.)
>> Error bar plots are easier to do in the ggplot2 package, since there
>> is a specific function to generate the error bar 'geometry'
>> (geom_errorbar). See http://docs.ggplot2.org/current/ for an expanded
>> version of the package help pages, which include the graphs generated
>> by the code. I believe there's also a base graphics version that you
>> can get from the gplots package, but I don't know a lot about it.
>> On Thu, Jul 4, 2013 at 2:53 PM, Shaun Jackman <sjackman at gmail.com> wrote:
>>> I'd like to draw a lattice barchart of means with error bars to show
>>> the standard deviation. I have the barchart, how do I add the error
>>> x <- aggregate(weight ~ Diet, ChickWeight, function(x) c(mean=mean(x),
>>> barchart(weight[,'mean'] ~ Diet, x)
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide
>>> and provide commented, minimal, self-contained, reproducible code.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Alameda, CA, USA
More information about the R-help