Hi, I have a vector of data, that I group based on two factors via tapply. For each such grouping I would like to plot a pie chart. I can layout these pie charts in a matrix layout, correpsonding to the levels of the two factors. But I am getting stuck on how to label the rows and colums. My current approach looks like this:
x <- data.frame(obs=sample(c('low', 'high'),100, replace=TRUE), grp1=sample(1:10, 100, replace=TRUE), grp2=runif(100)) cut.grp1 <- cut(x$grp1, 3) cut.grp2 <- cut(x$grp2, 3) par(mfrow=c(3,3)) tapply(x$obs, list(cut.grp1, cut.grp2), function(z) { pie(table(z), col=c('red', 'green')) }) One possibility is to add an extra row and column to the layout and loop over the results of the tapply, adding a text label for the row and column labels. Is there a better way to achieve this? -- Rajarshi Guha NIH Chemical Genomics Center ______________________________________________ R-help@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.