Skip to content
Prev 295628 / 398502 Next

Correlograms: using boxes and different variables on rows and columns

In general, when you have a question about a package, it is best to
contact the package author directly.  (In this case, me).

1. Easy.  You just have to define your own panel function.  I just
modified panel.shade to create panel.bar

panel.bar <- function(x, y, corr=NULL, ...){

  usr <- par()$usr
  minx <- usr[1]; maxx <- usr[2]
  miny <- usr[3];  maxy <- usr[4]

  if (is.null(corr))
    corr <- cor(x, y, use = "pair")
  ncol <- 14
  pal <- col.corrgram(ncol)
  col.ind <- as.numeric(cut(corr, breaks = seq(from = -1, to = 1,
                                    length = ncol + 1), include.lowest = TRUE))
  col.bar <- pal[col.ind]
  if(corr < 0) {
    maxy <- miny + (maxy-miny) *  abs(corr)
    rect(minx, miny, maxx, maxy, col = pal[col.ind],
         border = "lightgray")
  } else if (corr > 0){
    miny <- maxy - (maxy-miny)*corr
    rect(minx, miny, maxx, maxy, col = pal[col.ind],
         border = "lightgray")
  }

}

corrgram(auto, order=TRUE, main="Auto data (PC order)", upper.panel=panel.bar)

2.  Harder.  You need to create your own copy of the corrgram function
and change it.  Look for the call to par() and change the number of
rows and columns.   Then change the loops over i and j to include only
the row and column numbers that you want instead of all rows and
columns.

Kevin
On Fri, May 25, 2012 at 8:38 AM, dadrivr <dadrivr at gmail.com> wrote: