Home > OS >  Can't delete dendogram and clustering on heatmap R
Can't delete dendogram and clustering on heatmap R

Time:12-04

I've got the following function on R. The idea is to receive a vector of length 400 with values between 0 and 1 and to create a heatmap with those values.

display_pattern <- function(x){
  x <- unlist(x)
  mat <- matrix(x, 20, byrow=T)
  heatmap(mat, Rowv=FALSE, Colv=FALSE)
}

If I call the function outside and try it with an example, the heatmap appears but Rowv and Colv don't seem to work.

display_pattern(patterns[257,1:400])

With the function

I've also tried putting the code outside the function, and the result is what I would like it to be, which is this:

heatmap(matrix(unlist(patterns[257,1:400]), 20, byrow=T), Rowv=NA, Colv=NA)

Outside the function

How could I fix it? Thanks in beforehand

CodePudding user response:

Your two heatmap statements (inside and outside the function) are different. Outside the function, you correctly used Rowv=NA, Colv=NA. Inside the function, you incorrectly used Rowv=FALSE, Colv=FALSE

  • Related