[R] Plotcorr: colour the ellipses to emphasize the differences
Gregor.Gorjanc at bfro.uni-lj.si
Sun Oct 17 02:51:58 CEST 2004
Hello R users!
I began with R and I must say that it is really nice. I have data with a lot of variables
and have a problem to extract the pattern from correlation matrix. So I tried with plotcorr
and it went fine. While I was reading the help page of this function, I found that ellipse
display can be even better with use of different colors (the code is bellow). However I have
a problem to understand the process of generating the colors. The function cm.colors() with argument 11 produces scale of colors with 11 points. What is the meaning of [5*xc + 6])? If I ommit this part from the code, I see that ellipses bellow diagonal do not have the same color as above the diagonal. In given example numbers 5 and 6 are given (I think so) since there are 11 variables in dataset mtcars.
How can one use this setup for other datasets? For example I have a dataset with 15 variables.
I would also like to know if it is possible to use some other scale of colors instead of cm.colors, rainbow, heat.colors, terrain.colors, topo.colors. I would like to have positive correlations in blue and nagative ones in red spectrum of colors. Is it possible?
# Colour the ellipses to emphasize the differences
corr.mtcars <- cor(mtcars)
ord <- order(corr.mtcars[1,])
xc <- corr.mtcars[ord, ord]
plotcorr( xc, col=cm.colors(11)[5*xc + 6])
With regards, Lep pozdrav
More information about the R-help