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
Controlling Order of Panels in Lattice Trellis Plots
13 messages · Rich Shepard, Bert Gunter, David Winsemius +2 more
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.html
Many pointers have been offered, but you have refused to heed them.
and provide commented, minimal, self-contained, reproducible code.
David Winsemius Alameda, CA, USA
On Fri, 22 Feb 2013, David Winsemius 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.
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:
xyplot(sb.d$quant ~ sb.d$sampdate | sb.d$site, ylim=range(sb.d$quant), xlim=range(sb.d$sampdate), main='Antimony By Time', ylab='Concentraion (mg/L)', xlab='Time')
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: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.html
Many pointers have been offered, but you have refused to heed them.
and provide commented, minimal, self-contained, reproducible code.
-- David Winsemius Alameda, CA, USA
______________________________________________ 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
On Feb 22, 2013, at 11:29 AM, Rich Shepard wrote:
On Fri, 22 Feb 2013, David Winsemius 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.
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:
xyplot(sb.d$quant ~ sb.d$sampdate | sb.d$site, ylim=range(sb.d$quant), xlim=range(sb.d$sampdate), main='Antimony By Time', ylab='Concentraion (mg/L)', xlab='Time')
My response can be seen on your cross-posted SO question.
David Winsemius Alameda, CA, USA
On Fri, 22 Feb 2013, Bert Gunter wrote:
Manually change the ordering of the levels in the factor to that which you want (see ?factor if necessary) and replot.
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.
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
On Fri, Feb 22, 2013 at 1:22 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
On Fri, 22 Feb 2013, Bert Gunter wrote:
Manually change the ordering of the levels in the factor to that which you want (see ?factor if necessary) and replot.
Bert, I'll do this. I looked at ?factor and will try is.ordered() to see if that makes a difference. Many thanks, 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
On Feb 22, 2013, at 1:22 PM, Rich Shepard wrote:
On Fri, 22 Feb 2013, Bert Gunter wrote:
Manually change the ordering of the levels in the factor to that which you want (see ?factor if necessary) and replot.
Bert, I'll do this. I looked at ?factor and will try is.ordered() to see if that makes a difference.
`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.
David Winsemius Alameda, CA, USA
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
On Fri, 22 Feb 2013, David Winsemius 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.
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:
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
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:
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.