Skip to content

Controlling Order of Panels in Lattice Trellis Plots

13 messages · Rich Shepard, Bert Gunter, David Winsemius +2 more

#
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
#
On Feb 22, 2013, at 11:02 AM, Rich Shepard wrote:

            
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.

        
Many pointers have been offered, but you have refused to heed them.

  
    
#
On Fri, 22 Feb 2013, David Winsemius wrote:

            
Yes, David, strip labels are factors. What sort of detail would you like
to see to advise me on how to specify the order of these factors?

   Do you want a data set?

   Here is an example command:
Rich
#
Manually change the ordering of the levels in the factor to that which
you want (see ?factor if necessary) and replot.

-- Bert

On Fri, Feb 22, 2013 at 11:17 AM, David Winsemius
<dwinsemius at comcast.net> wrote:

  
    
#
On Feb 22, 2013, at 11:29 AM, Rich Shepard wrote:

            
My response can be seen on your cross-posted SO question.
#
On Fri, 22 Feb 2013, Bert Gunter wrote:

            
Bert,

   I'll do this.

   I looked at ?factor and will try is.ordered() to see if that makes a
difference.

Many thanks,

Rich
#
You do not need to use ordered factors.

newfac <- factor(oldfac, lev= ...) ## will do it. e.g.
[1] a b c
Levels: a b c
[1] a b c
Levels: c b a

-- Bert
On Fri, Feb 22, 2013 at 1:22 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:

  
    
#
On Feb 22, 2013, at 1:22 PM, Rich Shepard wrote:

            
`is.ordered` will return TRUE if it is an ordered factor. That's not what you want to know and using `as.ordered` would also fail to provide the needed ordering. You need to provide a proper levels argument to the factor function. And you will find that making an ordered factor will probably have undesirable side effects.
#
On Fri, 22 Feb 2013, Bert Gunter wrote:

            
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
#
On Fri, 22 Feb 2013, David Winsemius wrote:

            
Thank you, David. That was the conclusion I was approaching as I tried
is.ordered and as.ordered and saw they did not affec the needed changes.
I'll look at levels or sort the input data file before reading it into R.

Rich
#
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:

  
    
2 days later
#
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:
[1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13"
[1] "1"  "10" "11" "12" "13" "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"
HTH
#
Hi
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