Parseltongue
Parseltongue

Reputation: 11657

R: Extract row indices from list

I ran outlierTest from the car package (outliers <- car::outlierTest(mod)) and it returned the following list object

        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

I want to extract the dataframe indices that it references on the left side. I assumed these would be accessible via row.names, but was incorrect. How do I grab these?

Upvotes: 0

Views: 102

Answers (1)

joran
joran

Reputation: 173527

By using str() on the output of outlierTest it seems the row names that end up being printed are just stored in a names attribute of several of the object list elements, like rstudent.

So you could just do something like attr(x = x$rstudent,"names").

Upvotes: 3

Related Questions