【问题标题】:How to get row names of a data frome from row index values in R如何从 R 中的行索引值中获取数据的行名
【发布时间】:2013-08-08 21:56:35
【问题描述】:

我有一个名为 dat 的数据框。我在一个名为 maxIndex.numeric 的数字向量中有行索引。我想从 dat 中检索与 maxIndex.numeric 向量中的值相对应的所有行名。我尝试了以下方法,但错误如下所示:

行名(子集(dat,x == maxIndex.numeric))

字符(0) 警告信息: 在 x == maxIndex.numeric : 较长的对象长度不是较短对象长度的倍数

谢谢

【问题讨论】:

  • 不确定我是否做对了......一个可重现的例子会很好,但你试过rownames(dat)[c(maxIndex.numeric)]

标签: r


【解决方案1】:

应该这样做:

rownames(dat)[maxIndex.numeric]  

【讨论】:

    猜你喜欢
    • 2014-12-25
    • 2014-04-27
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 2011-01-23
    • 2013-07-19
    • 2017-11-29
    • 1970-01-01
    相关资源
    最近更新 更多