[R] Lattice strip with custom shingle.interval

Alex van der Spek doorz at xs4all.nl
Mon Mar 18 19:02:09 CET 2013


Trying to make a strip in lattice xyplots to display shingle intervals
with a sensible number of digits:


First I make a 2x2 matrix with rounded values of the shingle itnervals:

lec <- round(matrix(unlist(levels(equal.count(sd$Frother))), ncol = 2,
byrow = TRUE), 3)

Next I make a custom strip function to handle the difference between a
factor proper and a shingle:

my.strip <- function(which.given, which.panel, ..., shingle.intervals) {
		if (which.given == 1) {
			strip.default(which.given, which.panel, ...,strip.name = FALSE,
strip.levels = TRUE, shingle.intervals = lec)
		} else {
			strip.default(which.given, which.panel, ..., strip.name = FALSE,
strip.levels = TRUE)
		}
}

Then the call to xyplot.

xyplot(Grade ~ Recovery| equal.count(Frother) + Row,
       groups = interaction(Row1.Mode, Row3.Mode, drop = TRUE),
       data = sd, pch = 1, layout = c(6,2),
       main = 'By Row and Frother dosing',
	 strip = my.strip,
       sub = 'Colour indicates control mode',
	 auto.key = list(columns = 5))


This however still gives full precision levels.

Any help much appreciated.

Alex van der Spek



More information about the R-help mailing list