用R語言檢索文獻並簡單整理信息

起因:在工作中需要閱讀文獻,其中的一些基本信息,例如文章作者,發表刊物,影響因子等,自己懶,不想一一整理

基本利用思路:利用R語言中的RISmed包檢索並進行返回需要的基本信息,如第一作者,責任作者,作者單位,發表期刊,這些都是RISmed包中既有的函數可以得到的,然後利用下載的期刊影響因子列表提取IF,最後把上述信息輸出成爲excel表格。

上述功能很多軟件都能做,我想以上面爲基礎做下面的事:

    1. 篩選最相關的研究:pubmed的結果大家都知道是比較全面的,但是有時候冗餘比較多,如何進一步分析自動篩選最相關的研究是一個問題。

    2. 進一步篩選引用了某一論文的論文。

    3. 通過文本分析,得到相關研究的發展趨勢是另外一個問題。這兩個問題涉及到各個專業的特性,不是僅僅用一下文本分析,詞頻等等就可以的。我想可能與專業論文撰寫習慣,專業詞彙表的建立,專業詞彙的權重等等諸多問題有關。之後再研究。

現在的腳本很簡單,但是好歹現在解決了第一個問題:我拿到文獻了!!(撒花,撒花……小白做成了一點小事後莫名的開心)

腳本分享一下。我不是搞軟件的,也不是專門做情報分析的,純粹個人惡趣味,非要把其他軟件能做的事情用R做一下。因爲其實很簡單,學習交流用。


##說明:採用RISmed包,檢索pubmed,關鍵詞可根據pubmed檢索技巧填寫。

##(cont)可設置檢索時間範圍,可輸出2018影響因子,主題詞,等信息

##(cont)與在pubmed上檢索比對,最新的幾篇文獻檢索不到,其他的基本類似

##(cont)可輸出每次應用的log

library(tidyverse)

library(RISmed)

library(openxlsx)

library(lubridate)

library(readxl)

#searching

#example for key words, myeloma[ti] jones[au]

#ab, ad:address, ta:journal name

#logic: AND OR NOT

purpose <- "training"

key_words <- c("pinkeye")

date_range_min = 2015

latest <- year(ymd(Sys.Date()))

date_range_max = latest

res <- EUtilsSummary(query = key_words, type = "esearch", db = "pubmed", datetype = "ppdt",

                    mindate = date_range_min, maxdate = date_range_max, retmax = 500)

query_word <- QueryTranslation(res)

query_word

number <- QueryCount(res)

number

#retreival journal name####

journal <- ISOAbbreviation(EUtilsGet(res))

full_journal <- tolower(Title(EUtilsGet(res)))

#impact factor####

if2018 <- read_excel("retrieval papers from ncbi/2018年最新影響因子.xlsx",

                    col_types = c("numeric", "text", "text",

                                  "numeric", "numeric"))

if2018$Total_Cites <- as.numeric(gsub(",","",if2018$Total_Cites))

if2018$Full_Journal_Title <- tolower(if2018$Full_Journal_Title)

if2018_final <- left_join(data.frame(full_journal), if2018, by = c("full_journal" = "Full_Journal_Title"))

#author####

authors <- Author(EUtilsGet(res))

author_1st <- c()

l <- length(authors)

for (i in 1:l) {

  names <- authors[[i]][authors[[i]]$order == 1,]

  name <- paste(names$LastName, names$Initials, sep = ",")

  author_1st <- c(author_1st, name)

}

author_last <- c()

for (i in 1:l) {

  total_author <- nrow(authors[[i]])

  names <- authors[[i]][authors[[i]]$order == total_author,]

  name <- paste(names$LastName, names$Initials, sep = ",")

  author_last <- c(author_last, name)

}

#titles####

titles <- ArticleTitle(EUtilsGet(res))

#affiliations####

affiliations <- Affiliation(EUtilsGet(res))

affiliation_1st <- c()

for (i in 1:l) {

  aff <- affiliations[[i]][1]

  affiliation_1st <- c(affiliation_1st, aff)

}

#pub time####

year_pub <- YearPubmed(EUtilsGet(res))

#citation times####

cited_num <- Cited(EUtilsGet(res))

#article ID####

article_id <- ArticleId(EUtilsGet(res))

#mesh####

meshes <- Mesh(EUtilsGet(res))

mesh <- c()

for (i in 1:l) {

  if (is.na(meshes[[i]])) {

    mesh2 <- NA

    mesh <- c(mesh, mesh2)

  }

  else {

    mesh1 <- meshes[[i]]

    n <- nrow(mesh1)

    mesh2 <- mesh1$Heading[1]

    for (j in 2:n) {

      mesh2 <- paste(mesh2, mesh1$Heading[j], sep = ", ")

    }

    mesh <- c(mesh, mesh2)

  }

}

#combine all####

all_output <- data.frame(journal, year_pub, IF = if2018_final$Journal_Impact_Factor,author_1st, author_last, cited_num,

                        affiliation_1st, titles, mesh, article_id)

all_output %>% View()

path <- paste(key_words, ".xlsx")

write.xlsx(all_output, path)

#Log file####

Sys.Date()

purpose

key_words

query_word

number

log_exist <- read_excel("log for RISmed search.xlsx")

log_exist$date <- as.Date(log_exist$date)

log_present <- data.frame(date = Sys.Date(), purpose, key_words, query_word, number)

log_present <- bind_rows(log_exist, log_present)

write.xlsx(log_present, "log for RISmed search.xlsx", overwrite = T)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章