change facet order

1,457 views
Skip to first unread message

squid

unread,
Dec 15, 2009, 4:59:51 AM12/15/09
to ggplot2
Hi,

I am using facet wrap but would like to change the order of the facets
so that they are not alphabetically or numerically ordered.

I am using the facet wrap command
facet_wrap(~arm, ncol=1,scales = "fixed")

where

> summary(wins$arm)
2L 2R 3L 3R X

The facets appear in that order, but I would like them to appear in
the following order (which is the order they are in in my data.frame):
2R 2L 3R 3L X

Thanks!
squid.

hadley wickham

unread,
Dec 15, 2009, 9:44:09 AM12/15/09
to squid, ggplot2
Change the order of the underlying factor.

Hadley

--
http://had.co.nz/

squid

unread,
Dec 17, 2009, 10:33:48 AM12/17/09
to ggplot2
Thanks! Specifically, I had to enter

wins$arm<-factor(wins$arm, levels=c("2R", "2L", "3R", "3L", "X")

Then the facets were ordered in that way.


On Dec 15, 2:44 pm, hadley wickham <h.wick...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages