[R] > Understanding strip.default & strip.custom
Duncan Mackay
dulcalma at bigpond.com
Tue Jun 28 08:55:10 CEST 2016
Hi Patrick
does this help?
dat <-
data.frame(x = rnorm(12*5,0,1),
y = rnorm(12*5,0,1),
gp = factor(1:12))
dat$NS = ifelse(sapply(dat$gp, pmatch,flN, nomatch = 0) > 0, "Needles","Stems")
dat = dat[order(dat[,"NS"]),]
dat$GP = factor(1:6)
xyplot(y ~ x|gp, data = dat,
par.settings = list(strip.background = list(col = "transparent")
),
strip = strip.custom(factor.levels = expression(Needles~ "::"~alpha -pinene,
Stems~ "::"~alpha -pinene,
Needles~ "::"~beta -pinene,
Stems~ "::"~beta -pinene,
Needles~ ":: B?Phellandrene",
Stems~ ":: B?Phellandrene",
Needles~ ":: Camphene",
Stems~ ":: Camphene",
Needles~ ":: Myrcene",
Stems~ ":: Myrcene",
Needles~ ":: Limonene",
Stems~ "::Limonene"),
par.strip.text = list(cex = 0.65) ))
library(latticeExtra)
useOuterStrips(strip = strip.custom(factor.levels = expression("::"~alpha -pinene,
"::"~beta -pinene,
":: B?Phellandrene",
":: Camphene",
":: Myrcene",
":: Limonene")),
xyplot(y ~ x|GP*NS, data = dat,
drop.unused = T,
par.settings = list(strip.background = list(col = "transparent")
),
par.strip.text = list(cex = 0.65) )
)
If you want to change the order of the factors assign the factor levels to a vector and order accordingly
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of p_connolly
Sent: Tuesday, 28 June 2016 12:59
To: r-help at stat.math.ethz.ch
Subject: [R] > Understanding strip.default & strip.custom
I'm having difficulty following the help for those functions.
My plot has a single conditioning factor with 12 levels. My
factor.levels in a call to strip.default looks like this:
factor.levels = expression(Needles~ "::"~alpha -pinene,
Stems~ "::"~alpha -pinene,
Needles~ "::"~beta -pinene,
Stems~ "::"~beta -pinene,
Needles~ ":: B−Phellandrene",
Stems~ ":: B−Phellandrene",
Needles~ ":: Camphene",
Stems~ ":: Camphene",
Needles~ ":: Myrcene",
Stems~ ":: Myrcene",
Needles~ ":: Limonene",
Stems~ "::Limonene")
Since there is only one factor, which.given must be 1.
Likewise, var.name must be of length 1.
What I can't understand is the argument which.panel. The help says:
which.panel: vector of integers as long as the number of conditioning
variables. The contents are indices specifying the current
levels of each of the conditioning variables (thus, this
would be unique for each distinct packet). This is identical
to the return value of ‘which.packet’, which is a more
accurate name.
So, that must be of length 1 also, according to the first sentence,
but if I set it to 1, I get the first strip label repeated 12 times.
Set it to 2, I get the second one 12 times. Set it to 1:2, it
attempts to squash 2 strips in the space of 1, labelling the first
one. I don't understand the second sentence at all.
What do I do to get all 12 in their correct order?
I couldn't find an example remotely like what I'm trying to do. Are
there any pointers?
TIA
Patrick
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
More information about the R-help
mailing list