[R] Order of Dotplot output

Deepayan Sarkar deepayan.sarkar at gmail.com
Sat Oct 20 00:18:51 CEST 2007


On 10/19/07, Allison Bailey <allison at soundgis.com> wrote:
> Thanks for the suggestions.  The factor function on the RYEAR column worked well.
>
> I need to clarify my question about the order of the plot.   as.table appears to be concerned with the order that each panel is plotted.  Is that correct?
>
> I'm interested in controlling the order of the elements on the y-axis of the graph.  Right now, the species are listed in reverse alphabetical order.  I'm interested in having them in alphabetical order or in order by the magnitude of their values (highest on the top, to lowest on the bottom).  Any additional suggestions?
>

Can't think of anything simpler than changing the order of the levels:

> foo = data.frame(a = gl(10, 1), x = sort(runif(10)))
> dotplot(a ~ x, foo)
> dotplot(factor(a, levels = rev(levels(a))) ~ x, foo)

-Deepayan



More information about the R-help mailing list