使用其他因素对因子进行排序

时间:2014-04-07 10:20:20

标签: r ggplot2 s

我使用本教程使用ggplot2

绘制热图

http://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/

现在我想用相同长度的另一个因子来命令垂直因子。

strains x1 x2 x3 origin
name     4 2  4   see

有人知道它是如何运作的吗?

由于

1 个答案:

答案 0 :(得分:0)

如果您在 nba 中有一个额外的列,例如nba$country,那么您可以通过

调整原始排序
nba$Name <- with(nba, reorder(Name, country))

如果你有一个你想要订购的替代注释,那么你需要匹配它。例如,如果你有一个玩家国家data.frame(PC),那么

nba$Name <- reorder(nba$Name, PC$country[match(nba$Name, PC$Name)])