Skip to content

Instantly share code, notes, and snippets.

@mcguinlu
Last active April 9, 2020 14:55
Show Gist options
  • Save mcguinlu/3cae2773cdc39dd6a94c827c00bc9fcb to your computer and use it in GitHub Desktop.
Save mcguinlu/3cae2773cdc39dd6a94c827c00bc9fcb to your computer and use it in GitHub Desktop.
Script to find references linked by common authorship in a .bib file
library(bib2df)
library(dplyr)
get_common_authors <- function(data){
data$related <- character(dim(data)[1])
for (test.row in 1:dim(data)[1]) {
test.authors <- unlist(data[test.row,5])
for (data.row in 1:dim(data)[1]) {
if (any(test.authors %in% unlist(data[data.row,]))==TRUE & test.row != data.row) {
data$related[data.row] <- paste0(data$related[data.row],", ",data$BIBTEXKEY[test.row])
}
}
}
for (row in 1:dim(data)[1]) {
data$related[row] <- stringr::str_sub(data$related[row],3,nchar(data$related[row]))
}
data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment