[R] Correlation Mapping

Gabor Grothendieck ggrothendieck at gmail.com
Mon Jul 17 07:52:35 CEST 2006


I have not seen that book cover but I assume the
question is how to plot the cells of a correlation
matrix in different colors.  Try heatmap or the gplot
package function heatmap.2 .  For example, we create a
correlation matrix, K, from the first 4 columns of
the iris data set and create a heatmap using the
bluered color scheme:

# heatmap.2
library(gplots)
K <- cor(iris[,1:4])
heatmap.2(K, col = bluered(16), cexRow = .7, cexCol = .7, symm = TRUE,
	dend = "row", trace = "none", main = "Iris Data")

balloonplot, also in the gplots package, and image in graphics (i.e. core R)
might be other functions to look at.

On 7/16/06, justin rapp <jdrapp at gmail.com> wrote:
> On the cover of Zivot and Wang's Modeling Financial Time Series with S
> Plus, there is a correlation plot that seems to indicate the strength
> of correlation with color-coded squares, so that more highly
> correlated stocks appear darker red.  If anybody out there is familiar
> with the book or understands what I am talking about, I am curious as
> to whether or not there is a similar function in R and how I can call
> it up.
> Thank you.
>
> jdr
>
> ______________________________________________
> 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