[R] How to put given values in lower triangle of splom-plot?

Hofert Marius m_hofert at web.de
Sun Sep 21 11:11:51 CEST 2008


Dear R-experts,

I have found a splom-modification online which is given below. This  
works perfectly, but I would like to have a matrix of given  
correlation values to be used in the lower triangular part  
(lower.panel) of the splom-plot instead of calculated correlation  
values. Here is the matrix I would like to use (it can be any other  
convenient data structure):

mymat=matrix(0,nrow=3,ncol=3)
mymat[1,2]=0.2
mymat[1,3]=0.2
mymat[2,3]=0.5

If one can determine inside the lower.panel-function which columns of  
"data" are used for the current pairwise scatter plot, it should be  
easy to get the correct entries of "mymat", but how is this achieved?  
It would then be also possible to build a data structure of locations  
so that one can place the entries wherever convenient inside the gray  
rectangles.

Best regards.

Marius

#splom modification example
library(lattice)
data1=runif(100)
data2=data1+runif(100)
data3=data2+runif(100)
data=cbind(data1,data2,data3)
splom(~data[,1:3],upper.panel=panel.splom,
       lower.panel=function(x,y,...){
					panel.fill(col=gray(500:1000/1000)[round(501-500*cor(x,y))])
           panel.text(mean(x),mean(y),round(cor(x,y),2))
       },
cex=0.2,aspect=1,pscales=0,varnames=c("Component 1","Component  
2","Component 3"),xlab="",ylab="")



More information about the R-help mailing list