In R lattice, I am trying to label predefined groups of rows in a matrix of data with strips. Currently, the length of the strips fail to match the different sizes of the groups as the data representation only allows groups with the same size.
One possibility to solve this might be to suppress the display of NAs, but I did not find any configuration to realize this in Lattice. The example code below shows a matrix (m) with 8 rows and 4 columns. Group 1 contains row 1-5 and group 2 contains row 6-8. The lattice output is attached below the code. Thank you for your time library(lattice) m <- matrix(c(1,1,1,0,0,0,0,0, 0,0,1,1,1,0,0,0, 0,0,0,0,1,1,1,0, 0,0,0,0,0,0,1,1),nrow=8,ncol=4) group1 <- m[1:5,] group2 <- m[6:nrow(m),] plotMatrix <- array(dim=c(5,4,2)) dimnames(plotMatrix) <- list(rep("",5), c("a","b","c","d"),c("group1","group2")) plotMatrix[,,1]<- group1 plotMatrix[1:3,,2] <- group2 trellis.device(device = "pdf",file ="lattice_strips.pdf",width=14,height=10) print(levelplot(plotMatrix,colorkey=F,xlab="",ylab="")) dev.off()
lattice_strips.pdf
Description: Adobe PDF document
______________________________________________ R-help@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.