Dear R users, How to change lattice panel label/text from the automatically generated label (based on the conditioning) to our own set of label? for example: someStuff <- data.frame(area = rep(c("SOUTH", "NORTH", "EAST", "WEST"), each = 25), group = rep(c("A","B","C","D"), each = 5), mytime = rep(1:4), val1 = sample(1:100, size=100, replace=TRUE), val2 = sample(1:100, size=100, replace=TRUE) ) xyplot(val1+val2 ~ mytime | area * group, data = someStuff, type = c("a", "p", "g")) I want to change each panel label/text from for example D/East or D/North ... into Deriv/From East, Deriv/From North ... I know I could change from the data, but is there a way to change it from lattice ? thanks beforehand. [[alternative HTML version deleted]]
Hi, I believe you want to look at ?strip.custom someStuff <- data.frame(area = rep(c("SOUTH", "NORTH", "EAST", "WEST"), each = 25), group = rep(c("A","B","C","D"), each = 5), mytime = rep(1:4), val1 = sample(1:100, size=100, replace=TRUE), val2 = sample(1:100, size=100, replace=TRUE) ) xyplot(val1+val2 ~ mytime | area * group, data = someStuff, type = c("a","p", "g"), strip=strip.custom(factor.levels=letters[1:4])) Hope this helps, baptiste On 14 Oct 2008, at 00:43, Ferry wrote:> Dear R users, > > How to change lattice panel label/text from the automatically > generated > label (based on the conditioning) to our own set of label? > > for example: > > someStuff <- data.frame(area = rep(c("SOUTH", "NORTH", "EAST", > "WEST"), each > = 25), > group = rep(c("A","B","C","D"), each = 5), > mytime = rep(1:4), > val1 = sample(1:100, size=100, replace=TRUE), > val2 = sample(1:100, size=100, replace=TRUE) > ) > > xyplot(val1+val2 ~ mytime | area * group, data = someStuff, type = > c("a", > "p", "g")) > > I want to change each panel label/text from for example D/East or D/ > North > ... into Deriv/From East, Deriv/From North ... > > I know I could change from the data, but is there a way to change it > from > lattice ? > > thanks beforehand. > > [[alternative HTML version deleted]] > > ______________________________________________ > 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._____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag
http://lmdvr.r-forge.r-project.org/figures/figures.html Look at Figure 10.24 and the code therein. You will likely want to define your own strip function, and the code in strip.combined could be your guide. If you have Deepayan's book, you can find more details in the relevant section. Haris Skiadas Department of Mathematics and Computer Science Hanover College On Oct 13, 2008, at 7:43 PM, Ferry wrote:> Dear R users, > > How to change lattice panel label/text from the automatically > generated > label (based on the conditioning) to our own set of label? > > for example: > > someStuff <- data.frame(area = rep(c("SOUTH", "NORTH", "EAST", > "WEST"), each > = 25), > group = rep(c("A","B","C","D"), each = 5), > mytime = rep(1:4), > val1 = sample(1:100, size=100, replace=TRUE), > val2 = sample(1:100, size=100, replace=TRUE) > ) > > xyplot(val1+val2 ~ mytime | area * group, data = someStuff, type = c > ("a", > "p", "g")) > > I want to change each panel label/text from for example D/East or D/ > North > ... into Deriv/From East, Deriv/From North ... > > I know I could change from the data, but is there a way to change > it from > lattice ? > > thanks beforehand. > >
On 10/13/08, Ferry <fmi.mlist at gmail.com> wrote:> Dear R users, > > How to change lattice panel label/text from the automatically generated > label (based on the conditioning) to our own set of label? > > for example: > > someStuff <- data.frame(area = rep(c("SOUTH", "NORTH", "EAST", "WEST"), each > = 25), > group = rep(c("A","B","C","D"), each = 5), > mytime = rep(1:4), > val1 = sample(1:100, size=100, replace=TRUE), > val2 = sample(1:100, size=100, replace=TRUE) > ) > > xyplot(val1+val2 ~ mytime | area * group, data = someStuff, type = c("a", > "p", "g")) > > I want to change each panel label/text from for example D/East or D/North > ... into Deriv/From East, Deriv/From North ... > > I know I could change from the data, but is there a way to change it from > lattice ?Using a strip function is the most general way, but can get a bit complicated with two variables. Changing the labels is really the easiest way; e.g., xyplot(val1+val2 ~ mytime | factor(area, labels = c("From East", ...)) * factor(group, ...)) You could also change the 'dimnames' of the resulting object before plotting:> p <- xyplot(val1+val2 ~ mytime | area * group, data = someStuff) > dimnames(p)$area [1] "EAST" "NORTH" "SOUTH" "WEST" $group [1] "A" "B" "C" "D"> dimnames(p)$area <- ... > plot(p)-Deepayan