1

I am conducting a meta-analysis. I am using the influence() command for outlier detection.

So what I did is the following:

outlier1 <- influence(result)
print(outlier1)

This gives me 250 entries indicating whether a study has to be excluded. Then I have to delete outlier studies by indicating the row. And here's the thing: I have 250 studies, and I don't want to count the rows manually in order to know which studies to exclude.

Here's what the result looks like:

Study Indicator_1 Indicator_N Outlier?
------------------------------------

(250 entries)

Now I would like to know how I can alter the printed result such that it looks like:

Number Study Indicator_1 Indicator_N Outlier?
--------------------------------------------

Counting should optimally start at 1.


Here is the data and code-sequence required for creating a reproducible example:

Data: http://www.filedropper.com/metadaten

Code sequence:

install.packages("xlsx")
install.packages("metafor")
library(xlsx)
library(metafor)

input <-read.xlsx("C:/Users/feal/Documents/BA_MA/Data/01. ID FP/meta_daten.xlsx", sheetName="input")

## View(input)

result <-rma(yi=zcor, vi=var, data=input, 
   measure="GEN", method="REML", level=95,
   slab=paste(author, pub_date, sep=", "))

print(result)

outlier1 <- influence(result)
print(outlier1)

After that I get the following results, a star on the right indicates that the outlier has to be removed.

Remove function as for an example:

input_out1 <-input[-19,]
print(input_out1)

I just want every column to have an entry number. Or every entry to be removed, where there is a star on the right.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Feal
  • 25
  • 5
  • Welcome to Stack Overflow! Can you please include data and/or code that will provide us with a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) ? – Ben Bolker Jun 08 '16 at 11:22

2 Answers2

0

Ok I got it myself.

If you are able convert the results such that the View() function can be used, above the console window in RStudio, the results will be shown with a line number prefix.

This is what made it work:

outputText <-capture.output(influence(result))

outputFrame = data.frame(outputText)

View(outputFrame)

Regards, Feal

Feal
  • 25
  • 5
  • 2
    I've edited your question to include this information (which is what you should have done in the first place ...) – Ben Bolker Jun 08 '16 at 11:53
  • I deleted the redundant content and added the solution where it should belong :). – Feal Jun 08 '16 at 18:17
0
data.frame(name=infl$dfbs$slab,
       rstu=infl[["is.infl"]])%>%filter(rstu==T)

Maybe this is all you need. You can modify the dataframe by looking at the output list of influence()