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

Fix Ace acefix at rocketmail.com
Mon Nov 21 21:14:19 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: "a" stays at the bottom of the heatmap.
 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!
Thanks.
Ace

	[[alternative HTML version deleted]]



More information about the R-help mailing list