'After printing influence() results from metafor package, how do I get a line number for each entry?
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.
Solution 1:[1]
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
Solution 2:[2]
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()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Ziqian Xia |
