[R] pairs correlations colors

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Sep 15 15:31:34 CEST 2004


Valeria Edefonti wrote:

> I have the following problem.
> I want to use pairs function and get a matrix of scatterplots with the  
> correlations in the upper panel and the ordinary scatterplots in the  
> lower panel.
> Moreover, I want to have points colored in five differet ways in the  
> lower panel, because I have five subgroups.
> In order to do that I tried to combine examples on pairs function help.
> I got a colored matrix using hints on iris dataset.
> I got a black and white matrix with correlations using function  
> panel.cor, exactly as it is in the example.
> Unfortunately, the line:
> 
> jpeg(filename="/home/valeria/Thesis/lung/fig/scatterplotcolnames.jpg")
> pairs(aggiunta[,1: 
> 6],labels=c("ALCAM","ITGB5","MSN","CSTB","DHCR24","TRIM29"), main =  
> "Scatterplots selected genes",pch=21,
> bg = c("red", "green3", "blue",  
> "brown","orange")[aggiunta[,7]],upper.panel=panel.cor)
> dev.off()
> 
> doesn't allow me to get the desidered matrix with colors and  correlations.
> I also tried to create a function panel.col for the lower.panel:
> 
> ## put colors on the lower panels
>      panel.col <- function(datiepheno)
>      {
>         usr <- par("usr"); on.exit(par(usr))
>         par(bg = c("red", "green3", "blue",  
> "brown","orange")[datiepheno[,7]],pch=21, usr = c(0, 1, 0, 1))
>     }
> 
> but it doesn't work as well.
> Any idea?
> I hope I'll be precise but not too much precise!
> Thank you very much
> Valeria


Looks like there was no answer yet:
Please specify am example with data available in R, so that we can 
reproduce your example. This will save much time for those people who 
are going to help.
Rearranging your examples with data we do not have available requires 
quite a lot of effort.

What I guess is that you are going to specify

lower.panel = function(x, y)
   points(x, y,
     col = sapply(aggiunta[,7], switch, "1"="red", "2"="green3", .....))


Uwe Ligges





> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list