bwplot reorder factor on y axis

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bwplot reorder factor on y axis

Michael Kubovy
Dear R-helpers,

In bwplot(pairL ~ asym, oppK) is a factor. It displays pairL in  
alphabetical order. How do I tell it to display, pairL in the order I  
wish , i.e., so the medians of asym are in ascending order?


_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766
WWW:    http://www.people.virginia.edu/~mk9y/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: bwplot reorder factor on y axis

Mark Herzog
?factor (specifically, the levels= option)

oppK<-oppK[order(median(oppK$asym),]
oppK$pairL<-factor(oppK$pairL, levels=unique(oppK$pairL))
bwplot(pairL ~ asym, oppK)


Mark
Mark Herzog, Ph.D.
Program Leader, San Francisco Bay Research
Wetland Division, PRBO Conservation Science
4990 Shoreline Highway 1
Stinson Beach, CA 94970
(415) 893-7677 x308
[hidden email]

Michael Kubovy wrote:

> Dear R-helpers,
>
> In bwplot(pairL ~ asym, oppK) is a factor. It displays pairL in  
> alphabetical order. How do I tell it to display, pairL in the order I  
> wish , i.e., so the medians of asym are in ascending order?
>
>
> _____________________________
> Professor Michael Kubovy
> University of Virginia
> Department of Psychology
> USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
> Parcels:    Room 102        Gilmer Hall
>          McCormick Road    Charlottesville, VA 22903
> Office:    B011    +1-434-982-4729
> Lab:        B019    +1-434-982-4751
> Fax:        +1-434-982-4766
> WWW:    http://www.people.virginia.edu/~mk9y/
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: bwplot reorder factor on y axis

Brian Ripley
In reply to this post by Michael Kubovy
On Wed, 4 Jan 2006, Michael Kubovy wrote:

> In bwplot(pairL ~ asym, oppK) is a factor. It displays pairL in
> alphabetical order. How do I tell it to display, pairL in the order I
> wish , i.e., so the medians of asym are in ascending order?

Actually, it displays pairL in the order of its levels. Trellis for S came
with a function reorder.factor to re-order the levels, and base R has it
too.  There is a very similar example on ?reorder.  More generally, see
?levels

(There are other reorder.factor functions in Hmisc and gdata, which you
may need to avoid.)

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: bwplot reorder factor on y axis

Deepayan Sarkar
In reply to this post by Michael Kubovy
On 1/4/06, Michael Kubovy <[hidden email]> wrote:
> Dear R-helpers,
>
> In bwplot(pairL ~ asym, oppK) is a factor. It displays pairL in
> alphabetical order. How do I tell it to display, pairL in the order I
> wish , i.e., so the medians of asym are in ascending order?

See ?reorder.factor, which has a very similar example you can adapt.
In your case, you probably want something like:

bwplot(reorder(factor(pairL), asym, median) ~ asym, oppK)

The call to factor is unnecessary if pairL is already a factor.

Deepayan
--
http://www.stat.wisc.edu/~deepayan/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html