Hi I have not understood very well how to realize, in limma package, the design (using factor in model.matrix) to insert in lmFit. I have an experiment with 4 groups (a,b,c,d) with 3 replicates for each-one and i have to compare a vs b; c vs d; ( a&c )vs (b&d). List Sample in pdata is like this: 1a 1c 1b 1d 2a 2c 2b 2d 3a 3c 3b 3d How can i do this design with matrix model? thanks daniela
8rino-Luca Pantani
2004-Jul-05 14:57 UTC
[R] using perm.cond & index.cond in lattice package
Dear R users,
this is my first question to the list.
I hope it will be not a trivial one.
My problem is to change the order in which the panel are plotted in a
lattice/Trellis plot.
I've read the S-plus Trellis Graphics user manual, in which there is a
function called "reorder.factor",
that, as far as I can catch from ?xyplot, in the lattice package is
substituted by two others:
"index.cond" & "perm.cond"
here below the (fictitious) data
cbind.data.frame(TREAT=c(rep(c("YES", "NO"), each=12)),
OM=rep(rep(c(5, 1, 3, 7), each=3), 2),
LOCATION=rep(rep(c("here5%OM", "there1%OM",
"elsewhere3%OM",
"overthere7%OM"),
each=3), 2),
Y=c(rnorm(3, mean=5),rnorm(3, mean=1),rnorm(3,
mean=3),rnorm(3, mean=7),
rnorm(3, mean=6),rnorm(3, mean=2),rnorm(3,
mean=4),rnorm(3, mean=8))
)->mydframe
library(lattice)
bwplot(Y~TREAT|LOCATION, data=mydframe)
#The panels are plotted in alphabetical order, but I would rather have
something like
bwplot(Y~TREAT|OM, data=mydframe)
# i.e. the panels ordered by OM (Organic Matter) content
#but with LOCATION written in the strip.
#From
#str(bwplot(Y~TREAT|OM, data=mydframe))
#I can see that
# $ index.cond :List of 1
# ..$ : int [1:4] 1 2 3 4
# $ perm.cond : num 1
#so I tried
bwplot(Y~TREAT|LOCATION,
data=mydframe,
index.condlist((1:4)[order(unique(mydframe$OM[order(mydframe$LOCATION)]))])
)
#and it seems to work, but without the darker tag for OM in the strips.
Now I have one perplexity and one question:
The last "list((1:4)[order(...." works fine, but it seems to me
inelegant,
too complicate
and not practical for plots with
more factors.
Any suggestion to simplify/improve the matter?
How can I keep the tags in the strips, still ordering the panels by OM?
Thanks in advance.
PS
The following lines are copied from ?xyplot
(I suspect that "order.cond" stands for "index.cond",
since I cannot find it in any other page of the lattice help, nor in the
general help)
The order in which the panels are drawn depends on the order
in which the conditioning variables are specified ('g1'
varies fastest). Within a conditioning variable, the order
depends on the order of the levels (which for factors is
usually in alphabetical order). Both of these orders can be
modified using the 'order.cond' and 'perm.cond'
arguments,
typically in the 'update' method.
Ottorino-Luca Pantani, Universit?? di Firenze
Dip. Scienza del Suolo e Nutrizione della Pianta