R:从列表中提取行索引

时间:2019-01-23 20:57:01

标签: r

我从car包(outliers <- car::outlierTest(mod))中运行了outlierTest,它返回了以下列表对象

        rstudent                                        unadjusted p-value                                         Bonferonni p
101812 -15.10404 0.0000000000000000000000000000000000000000000000000016115 0.00000000000000000000000000000000000000000000037466
137979 -14.65162 0.0000000000000000000000000000000000000000000000013829000 0.00000000000000000000000000000000000000000032152000
138209 -13.73731 0.0000000000000000000000000000000000000000006308000000000 0.00000000000000000000000000000000000014666000000000
124997 -13.59990 0.0000000000000000000000000000000000000000041618000000000 0.00000000000000000000000000000000000096759000000000
62602  -13.42890 0.0000000000000000000000000000000000000000424190000000000 0.00000000000000000000000000000000000986230000000000
78196  -13.42374 0.0000000000000000000000000000000000000000454740000000000 0.00000000000000000000000000000000001057200000000000
195658 -12.52146 0.0000000000000000000000000000000000058519000000000001030 0.00000000000000000000000000000136059999999999999007
124931 -12.07768 0.0000000000000000000000000000000014182999999999999254956 0.00000000000000000000000000032975000000000000085551
177689 -11.34566 0.0000000000000000000000000000079362999999999990162584378 0.00000000000000000000000184519999999999991835422130
82302  -10.66309 0.0000000000000000000000000153630000000000009271702167845 0.00000000000000000000357189999999999999516628564927

我想提取它在左侧引用的数据框索引。我以为可以通过row.names访问这些文件,但这是不正确的。我该如何抓取这些?

1 个答案:

答案 0 :(得分:3)

通过在str()的输出上使用outlierTest,看来最终要打印的行名称只是存储在几个对象列表元素的names属性中,例如rstudent。

所以您可以做类似attr(x = x$rstudent,"names")的事情。