[R] xyplot question

2005-12-06 Thread Christoph Scherber
Dear R users,

I have a question regarding the use of xyplot in the lattice() package. 
I have two factors (each with two levels), and I´d like to change the 
order of the panels in a 2x2 panel layout from the default alphabetic 
order that R uses based on the names of the factor levels.

My approach is (in principle)

xyplot(y~x|Factor1+Factor2)

Let´s assume, my factor levels for Factor1 are A and B,
and for Factor2 they´re C and D, respectively.

Now the default arrangement of my panels would be (from bottom top left 
to bottom right): BC,CA,BD,AD

What I´d like to have is BD,AC,BC,AD.

Can anyone tell me how to solve this problem easily?

I´ve read that using perm.cond and/or index.cond could solve this 
problem, but couldn´t find an appropriate example, unfortunately...

Thank you very much for your help!

Regards,
Christoph

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] xyplot question

2005-12-06 Thread Deepayan Sarkar
On 12/6/05, Christoph Scherber [EMAIL PROTECTED] wrote:
 Dear R users,

 I have a question regarding the use of xyplot in the lattice() package.
 I have two factors (each with two levels), and I´d like to change the
 order of the panels in a 2x2 panel layout from the default alphabetic
 order that R uses based on the names of the factor levels.

 My approach is (in principle)

 xyplot(y~x|Factor1+Factor2)

 Let´s assume, my factor levels for Factor1 are A and B,
 and for Factor2 they´re C and D, respectively.

 Now the default arrangement of my panels would be (from bottom top left

I assume you mean 'top left'

 to bottom right): BC,CA,BD,AD

No it won't, unless you meant

xyplot(y~x|Factor2+Factor1)

Instead of describing your problem 'in principle' (which can be very
confusing when you make a mistake), please do as the posting guide
asks and give a reproducible example. Anyone trying to answer you will
have to come up with an example anyway, and since it's your problem,
it might as well be you.

 What I´d like to have is BD,AC,BC,AD.

This is impossible if you have two conditioning factors (whichever way
you count, the combination following BD has to have at least one of
B and D in it). If you want to lose the 2-factor structure, create
an interaction, after which you can reorder its levels any way you
want, e.g.

d -
data.frame(f1 = sample(gl(2, 10, labels = LETTERS[1:2])),
   f2 = sample(gl(2, 10, labels = LETTERS[3:4])),
   x = rnorm(20),
   y = rnorm(20))

xyplot(y ~ x | f1:f2, d)[c(1, 2, 4, 3)]

which is a shortcut for

xyplot(y ~ x | f1:f2, d, index.cond = list(c(1, 2, 4, 3)))

-Deepayan

 Can anyone tell me how to solve this problem easily?

 I´ve read that using perm.cond and/or index.cond could solve this
 problem, but couldn´t find an appropriate example, unfortunately...

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] xyplot() question

2005-02-10 Thread Christoph Scherber
Dear R Users,
I have an xyplot() where different plotting symbols are used for 
subgroups (originally used within S-Plus, but hopefully it´s also 
applicable to R users).
How can I fit separate regression lines for every subgroup? So far, I 
can only plot the overall fitted line.

The code looks like this:
trellis.device()
sps-trellis.par.get(superpose.symbol)
sps$pch-1:7
trellis.par.set(superpose.symbol,sps)
spl - trellis.par.get(superpose.line)  
ps$lty - 1:7 
trellis.par.set(superpose.line,spl) 
xyplot(a~b|factor+treatment,
groups=external,data=ownframe,layout=c(2,2),
panel=function(x,y,subscripts,...){panel.superpose(x,y,subscripts,...);panel.lmline(x,y)}) 

Thank you very much for your help!
Regards
Christioph
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] xyplot() question

2005-02-10 Thread Deepayan Sarkar
On Thursday 10 February 2005 09:34, Christoph Scherber wrote:
 Dear R Users,

 I have an xyplot() where different plotting symbols are used for
 subgroups (originally used within S-Plus, but hopefully it´s also
 applicable to R users).
  How can I fit separate regression lines for every subgroup? So far,
 I can only plot the overall fitted line.

 The code looks like this:

 trellis.device()
 sps-trellis.par.get(superpose.symbol)
 sps$pch-1:7
 trellis.par.set(superpose.symbol,sps)

 spl - trellis.par.get(superpose.line)
 ps$lty - 1:7
 trellis.par.set(superpose.line,spl)
 xyplot(a~b|factor+treatment,
 groups=external,data=ownframe,layout=c(2,2),
 panel=function(x,y,subscripts,...){panel.superpose(x,y,subscripts,...
);panel.lmline(x,y)})

xyplot(a~b|factor+treatment,
   groups=external,data=ownframe,layout=c(2,2),
   panel.groups=function(x,y,...){ 
   panel.xyplot(x,y,...)
   panel.lmline(x,y,...)
   }) 

or

xyplot(a~b|factor+treatment,
   groups=external,data=ownframe,layout=c(2,2),
   type = c('p', 'r'))

Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html