首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >利用pubmedR实现doi搜索

利用pubmedR实现doi搜索
EN

Stack Overflow用户
提问于 2022-08-07 14:45:08
回答 1查看 66关注 0票数 0

尝试使用这里这里方法从doi列表中提取作者的隶属关系,但没有找到任何关于使用pubmedR进行doi搜索的信息。已经调查过转换语法,但也没有运气。请帮帮忙!谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-14 18:03:11

lol发现了这一点[ 这个职位的一个伟大的帮助],并希望为将来可能有同样问题的其他人发帖子。最后使用了easypubmed包而不是tho

代码语言:javascript
复制
library(easyPubMed)

#loading list of DOIs
dois <- read.csv("dois.csv")

#convering dois to their associated PMID's 
pmids <- lapply(dois, get_pubmed_ids)

#using pmid's to extract abstract & article information as an xml thing
abstracts <- c()
for (i in c(1:length(pmids))){
  if (is.character(pmids[[i]][["IdList"]][["Id"]])==TRUE){
  abstracts[i] <- fetch_pubmed_data(pmids[[i]])
  }
}
abstracts <-as.list(abstracts) 

#making the xml thing readable by R
readAbstracts <- c()
for (i in c(1:length(abstracts))){
  if (is.na(abstracts[[i]]) == FALSE){
    readAbstracts[[i]] <- read_xml(abstracts[[i]]) 
  }
}

#now extracting desired information from the abstracts object
 <- data.frame()
for (i in c(1:length(pmids)){
  if (is.na(abstracts[[i]]) == FALSE && length(pmids[[i]]$IdList)<2){
    index <- i
    curRent <- readAbstracts[[i]] 
    pmid    <- xml2::xml_find_first( curRent, ".//PMID") %>% xml2::xml_text()
    title    <- xml2::xml_find_first( curRent, ".//ArticleTitle") %>% xml2::xml_text()
    authors <- paste( 
      xml2::xml_find_all( curRent, ".//AuthorList/Author/LastName") %>% xml2::xml_text(),
      xml2::xml_find_all( curRent, ".//AuthorList/Author/ForeName") %>% xml2::xml_text(),
      sep = ", " )
    affiliate <- xml2::xml_find_all( curRent, ".//AuthorList/Author/AffiliationInfo[1]/Affiliation") %>% xml2::xml_text()
    if(is.na(affiliate[1])==TRUE){
      affiliate <- NA
    }
    if(is.na(authors[1])==TRUE){
      authors <- NA
    }
    if(length(authors)>length(affiliate)){
      authors <- authors[c(1:length(affiliate))]
    }
    df <- data.frame( pmid = pmid, title=title, authors = authors, affiliate = affiliate, i = i)
    extractedInfo <-  rbind(extractedInfo, df)
    }
}

然后,您可以使用各种方法来格式化“extractedInfo”,以满足您的需要。干杯

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73268414

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档