[R] dot plot with error bands

David Winsemius dwinsemius at comcast.net
Mon May 10 16:42:40 CEST 2010


On May 10, 2010, at 10:00 AM, Alexey Bessudnov wrote:

> Dear all,
>
> I'm trying to create a dot plot with error bands with
>
> Dotplot(labels ~ Cbind(estimate, lower, upper), data=For.plot)
>
> where estimate, lower and upper are numerical vectors, and labels is  
> a character vector that contains labels.
>
> The problem is that labels are automatically sorted alphabetically,  
> and I want them to be sorted by estimate (as in my data frame). This  
> should be straightforward, but unfortunately being new to R I can't  
> figure out how to do this. I'll appreciate your guidance.

Have you tried making "labels" (an unfortunate choice for a variable  
name, BTW) a factor variable with levels in the order of your desire?

(Also being new to R, you may not recognize the difference between a  
factor variable and a character vector, so producing a more explicit  
description of the dataframe "For.plot" with the str function ought to  
be your next contribution to this thread if the above solution is not  
effective.

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list