#data
set.seed(1234)
xm1 <- matrix(rnorm(100*10, rnorm(100, 0.5, 0.1)), nrow=100, ncol=10, byrow=FALSE)
xm2 <- matrix(rnorm(100*10, rnorm(100, 0.5, 0.1)), nrow=100, ncol=10, byrow=FALSE)
xm3 <- matrix(rnorm(100*10, rnorm(100, 0.5, 0.1)), nrow=100, ncol=10, byrow=FALSE)
dd <- cbind(xm1, xm2, xm3)
cor <- cor(dd)# calculate correlation matrix
require(ellipse)
plotcorr(cor, outline = TRUE, col = "darkgreen", numbers = FALSE, type = "full", diag = FALSE)
#heatmap plot for the data using ggplot2.
require(ggplot2)
# first need to reshape data to long form
require(reshape)
cor.melt <- data.frame(melt(cor) )
ggplot(cor.melt , aes(x=X1,y=X2, z= value)) + geom_tile(aes(fill= value)) + scale_fill_gradient(low="red", high="green") + theme_bw()
set.seed(1234)
xm1 <- matrix(rnorm(100*10, rnorm(100, 0.5, 0.1)), nrow=100, ncol=10, byrow=FALSE)
xm2 <- matrix(rnorm(100*10, rnorm(100, 0.5, 0.1)), nrow=100, ncol=10, byrow=FALSE)
xm3 <- matrix(rnorm(100*10, rnorm(100, 0.5, 0.1)), nrow=100, ncol=10, byrow=FALSE)
dd <- cbind(xm1, xm2, xm3)
cor <- cor(dd)# calculate correlation matrix
require(ellipse)
plotcorr(cor, outline = TRUE, col = "darkgreen", numbers = FALSE, type = "full", diag = FALSE)
#heatmap plot for the data using ggplot2.
require(ggplot2)
# first need to reshape data to long form
require(reshape)
cor.melt <- data.frame(melt(cor) )
ggplot(cor.melt , aes(x=X1,y=X2, z= value)) + geom_tile(aes(fill= value)) + scale_fill_gradient(low="red", high="green") + theme_bw()
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.