[R] How to override ordering of panels in xyplot()

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Mar 6 05:11:53 CET 2007


On 3/5/07, Michael Kubovy <kubovy at virginia.edu> wrote:
>
> Unless one makes the factor ordered, reordering the levels of a
> factor does not seem to be a trivial matter. The only R function I've
> found that makes it easy is reorder_factor() (package:reshape). Or am
> I missing something?

Don't think in terms of reordering factors, just create a new factor,
using a call to factor(), with a suitable 'levels' argument. It's
perfectly OK to call factor() on a factor; e.g.

> foo = factor(letters[1:4])
> foo
[1] a b c d
Levels: a b c d
> factor(foo, levels = rev(letters[1:4]))
[1] a b c d
Levels: d c b a

-Deepayan



More information about the R-help mailing list