Rich Shepard
2013-Feb-22 19:02 UTC
[R] Controlling Order of Panels in Lattice Trellis Plots
With multiple panels in a lattice trellis plot the sequence is, for example, 1, 10, 11, 12, 2, 3, 4. I want the sequence to be 1, 2, 3, 4, 10, 11, 12. Reading ?strip.default and the appropriate section in the Lattice book I'm not seeing how to specify the 'human' numeric order rather than the computer numeric order. A pointer will be appreciated. TIA, Rich
David Winsemius
2013-Feb-22 19:17 UTC
[R] Controlling Order of Panels in Lattice Trellis Plots
On Feb 22, 2013, at 11:02 AM, Rich Shepard wrote:> With multiple panels in a lattice trellis plot the sequence is, for > example, 1, 10, 11, 12, 2, 3, 4. I want the sequence to be 1, 2, 3, 4, 10, > 11, 12. >It appears these may be factors. No much in the way of code can be offered since you have provided none of hte requested details.> Reading ?strip.default and the appropriate section in the Lattice book I'm > not seeing how to specify the 'human' numeric order rather than the computer > numeric order. > > A pointer will be appreciated. >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlMany pointers have been offered, but you have refused to heed them.> and provide commented, minimal, self-contained, reproducible code.-- David Winsemius Alameda, CA, USA
Bert Gunter
2013-Feb-23 01:14 UTC
[R] Controlling Order of Panels in Lattice Trellis Plots
As you appear not to know, or at least have not stated, **what** you want to do, how can you expect anyone to tell you **how** to do it? Cheers, Bert On Fri, Feb 22, 2013 at 2:33 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:> On Fri, 22 Feb 2013, Bert Gunter wrote: > >> You do not need to use ordered factors. >> newfac <- factor(oldfac, lev= ...) ## will do it. e.g. >> >>> x <- factor(letters[1:3]) ## default ordering is alphabetic (mod locale) >>> x >> >> [1] a b c >> Levels: a b c >>> >>> y <- factor(x,lev=letters[3:1]) ## reorder the levels >>> y >> >> [1] a b c >> Levels: c b a > > > Bert, > > Makes sense. I wonder if this will work when only a portion of the site > IDs need to be explicitly ordered. There are 64 sites in all. Might be > easier to sort the text file. > > Thanks again, > > Rich > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Patrick Connolly
2013-Feb-25 04:35 UTC
[R] Controlling Order of Panels in Lattice Trellis Plots
On Fri, 22-Feb-2013 at 11:02AM -0800, Rich Shepard wrote: |> With multiple panels in a lattice trellis plot the sequence is, for |> example, 1, 10, 11, 12, 2, 3, 4. I want the sequence to be 1, 2, 3, 4, 10, |> 11, 12. |> |> Reading ?strip.default and the appropriate section in the Lattice book I'm |> not seeing how to specify the 'human' numeric order rather than the computer |> numeric order. |> |> A pointer will be appreciated. Without knowing what you're trying to do, I can't be sure, but I think this pointer could give you an idea:> cc <- 13:1 > levels(as.factor(cc))[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13"> levels(as.factor(as.character(cc)))[1] "1" "10" "11" "12" "13" "2" "3" "4" "5" "6" "7" "8" "9">HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
Hi> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Rich Shepard > Sent: Friday, February 22, 2013 11:33 PM > To: r-help at r-project.org > Subject: Re: [R] Controlling Order of Panels in Lattice Trellis Plots > > On Fri, 22 Feb 2013, Bert Gunter wrote: > > > You do not need to use ordered factors. > > newfac <- factor(oldfac, lev= ...) ## will do it. e.g. > > > >> x <- factor(letters[1:3]) ## default ordering is alphabetic (mod > >> locale) x > > [1] a b c > > Levels: a b c > >> y <- factor(x,lev=letters[3:1]) ## reorder the levels y > > [1] a b c > > Levels: c b a > > Bert, > > Makes sense. I wonder if this will work when only a portion of the > site IDs need to be explicitly ordered. There are 64 sites in all. > Might be easier to sort the text file.Any sorting of input text file do not change factor levels ordering in R which is by default alphabetic. Do not guess how the language works, learn the rules from documentation and help pages. If you learned some foreign language you need to know some vocabulary and grammar to express understandable thoughts. And mostly people are more intelligent than computers when dealing with incomplete and twisted sentences. Regards Petr> > Thanks again, > > Rich > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.
Reasonably Related Threads
- Lattice: Setting Conditioning Panel Order in Trellis Plots
- How to re-order panels and y-axis values in trellis display using lattice
- Missing panels in multipanel lme lattice/trellis
- [lattice] how to overlay a geographical map on a levelplot?
- Passing arguments to panels in trellis plots