[R] grid.table + splom: how to nicely align panel entries

From: Marius Hofert <m_hofert_at_web.de>
Date: Wed, 20 Apr 2011 11:16:26 +0200

Dear expeRts,

is there a way to get the entries in each panel correctly aligned according to the equality signs?

Here is the "wish-list":
(1) the equality signs in each panel should be vertically aligned (2) the numbers should be aligned on the decimal point

One could adjust the phantom()-arguments by hand to achieve (1), but is there a simpler solution? For (2) I have no idea.




## splom with customized lower.panel
## x: data
## arr: array of containing expressions which are plotted in a grid table in the
## lower panel (i,j)]
splom2 <- function(x, arr){

    ## function for creating table
    table.fun <- function(vec){ # vector containing lines for table for *one* panel

        grid.table(matrix(vec, ncol=2, byrow=TRUE),
                   parse=TRUE, # parse labels as expressions
                   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
                   core.just="left", padding.h=unit(0,"mm")) # justification of labels

    ## splom
    splom(x, varname.cex=1.4,
          superpanel=function(z, ...){
              panel.pairs(z, upper.panel=panel.splom, lower.panel=function(i,j){
              }, ...)


## create data and array of expressions
d <- 4
x <- matrix(runif(d*1000), ncol=d) # data to be plotted with splom arr <- array(list(rep(NA, 3*2)), dim=c(d,d,3*2), dimnames=c("i","j","val")) # array containing the table entries per panel f <- function(i,j) (i+j)*10+0.1 # dummy function for(i in 1:d){

    for(j in 1:d){

	arr[i,j,] <- c("alpha==phantom()", round(pi,4),
                       "italic(bbb)==phantom()", round(pi,6),
                       "gamma==phantom()", f(i,j))

## plot

splom2(x, arr)

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. Received on Wed 20 Apr 2011 - 09:19:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Apr 2011 - 10:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive