[R] how to use vector of values to change row order of a heatmap

Fix Ace acefix at rocketmail.com
Mon Nov 21 21:05:15 CET 2016


Hello, there,
R document for heatmap says that Rowv could be a vector of values to specify the row order. However, I couldn't figure out how to apply it. A simple example here:> b=as.data.frame(matrix(c(3,4,5,8,9,10,13,14,15,27,19,20),3,4))
> b
  V1 V2 V3 V4
1  3  8 13 27
2  4  9 14 19
3  5 10 15 20
> row.names(b)=c("a","b","c")
> b
  V1 V2 V3 V4
a  3  8 13 27
b  4  9 14 19
c  5 10 15 20
> heatmap(as.matrix(b))
What I got:
 

Now I would like to put row "a" to the top row, how do I do that?I tried provide a vector of values (all the possible combination of 1,2,3) to Rowv,  "a" is always stay at the bottom
Any input would be very helpful!
Ace
  

   
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 10962 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20161121/64a973c3/attachment.png>


More information about the R-help mailing list