I have following matrix wanted to create heatmap in R
E1 E2 P1 P2
E1 1 0.73867 0.865486 0.708944
E2 1 0.749623 0.949532
P1 1 0.747194
P2 1
I used following code to achieve it
acc<-read.csv("data.csv",header=TRUE,sep=",")
row.names(acc)<-acc[,1]
acc <- acc[,2:dim(acc)[2]]
acc_matrix<-data.matrix(acc)
acc_map <- heatmap_2(acc_matrix,Rowv=NA, Colv=NA, col = rev(heat.colors(256)),scale="none",legend=1)
But im getting error as follows
Error in `[.data.frame`(acc, , 1:dim(acc)[1]) :
undefined columns selected
Can anybody please help how to solve this...
Thanks
NI
Here's one solution using the ggheat function.
mat <- matrix(NA,ncol=4,nrow=4)
diag(mat) <- 1
library(gdata)
upperTriangle(mat) <- runif(6)
colnames(mat) <- rownames(mat) <- c("E1","E2","P1","P2")
ggheat(mat)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.