Search code examples
rrow-numberoutliers

Getting the row-index from an OutlierTest table


I have run an OutlierTest on a regression model and assigned it to a variable. The class of the table is also outlierTest. I want to extract the row index from this table.

I am not able to convert the table into a data.frame or a matrix.

> library(car)

> b <- outlierTest(fit_train2)

> b
     rstudent unadjusted p-value Bonferonni p
411  4.976415         1.0296e-06   0.00036243
372  4.160773         4.0193e-05   0.01414800
401 -3.987709         8.1658e-05   0.02874400
373  3.881285         1.2474e-04   0.04391000

I basically need something to extract 411, 372, 401 and 373 into another vector.

Alternatively, is there any function that provides me with the row-numbers of the influential observations in the data?


Solution

  • You can access any of the elements of the object and take the names of that. For example,

    names(b$bonf.p)
    

    or

    names(n[[1]])