Say I have a simple matrix A generated by
A = matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,ncol=3)
Now, my goal is to make a heatmap out of A, such that each number is replaced by a colour field. How to do that? I tried
heatmap(A)
but it produced three coloured stripes instead of 9 distinct fields.
One of the possibilities that have not been described in the solutions referred to in the comments consists in using the pheatmap package:
library(pheatmap)
A <- matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,ncol=3)
pheatmap(A, cluster_rows = FALSE, cluster_cols = FALSE)
which gives:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With