在循环中使用RefManageR从PMID获取PubMed信息
我正在尝试使用RefManageR和PubMed ID(PMID)从PubMed检索引文信息 我选择RefManageR是因为以data.frame格式粘贴输出非常容易。对我来说,仍然很难理解和单独使用PubMedAPI 我能够编写使用“PMID字符串”作为输入以获取数据的代码:在循环中使用RefManageR从PMID获取PubMed信息,r,loops,pubmed,R,Loops,Pubmed,我正在尝试使用RefManageR和PubMed ID(PMID)从PubMed检索引文信息 我选择RefManageR是因为以data.frame格式粘贴输出非常容易。对我来说,仍然很难理解和单独使用PubMedAPI 我能够编写使用“PMID字符串”作为输入以获取数据的代码: require(RCurl) urli <- getURL("https://gist.githubusercontent.com/aurora-mareviv/3840512f6777d5293218/raw/
require(RCurl)
urli <- getURL("https://gist.githubusercontent.com/aurora-mareviv/3840512f6777d5293218/raw/dfd6b76ceb22c52aa073fc05211dcea986406914/pmids.csv", ssl.verifypeer = FALSE)
pmids <- read.csv(textConnection(urli))
head(pmids)
index10 <- pmids$pmId[1:10]
indice10 <- paste(pmids$pmId[1:10], collapse=" ")
# install.packages("RefManageR")
library(RefManageR)
auth.pm10 <- ReadPubMed(indice10, database = "PubMed", mindate = 1950)
auth.pm10d <- data.frame(auth.pm10)
View(auth.pm10)
它给出以下错误:错误:内部服务器错误
但是,如果我插入指示符10
(字符串)而不是索引10
(向量),它可以工作:
cites <- extract.pub(indice10, dbase="PubMed")
View(cites)
citesReadPubMEd
每个函数调用只接受一个pmid或查询。尝试:
lapply(pmids[1:3], ReadPubMed, database = "PubMed", mindate = 1950)
给予
您可以将BibEntry
类的元素放入data.frame中,并很好地设置创作格式
lapply(pmids[1:3], function(x){
tmp <- unlist(ReadPubMed(x, database = "PubMed", mindate = 1950))
tmp <- lapply(tmp, function(z) if(is(z, "person")) paste0(z, collapse = ",") else z)
data.frame(tmp, stringsAsFactors = FALSE)
})
lappy(pmids[1:3],函数(x){
tmp谢谢,我没有想到apply!但是,我一直在尝试修改您的代码,以获得可以强制转换为data.frame的内容。例如:adata好的,ReadPubMed
返回的是类BibEntry
,实际上是大约13个元素的列表。因此,您可以将这些元素中的每一个都设置为列在data.frame中。据我所知,您不能将BibEntry类对象输出到data.frame中。我将编辑上面的答案
[[1]]
[1] P. M. Zeltzer, B. Bodey, A. Marlin, et al. “Immunophenotype profile of childhood
medulloblastomas and supratentorial primitive neuroectodermal tumors using 16 monoclonal
antibodies”. Eng. In: _Cancer_ 66.2 (1990), pp. 273-83. PMID: 2196109.
[[2]]
[1] L. C. Rome, R. P. Funke and R. M. Alexander. “The influence of temperature on muscle
velocity and sustained performance in swimming carp”. Eng. In: _The Journal of
experimental biology_ 154 (1990), pp. 163-78. PMID: 2277258.
[[3]]
[1] P. Henry. “[Headache, facial neuralgia. Diagnostic orientation and management]”. Fre.
In: _La Revue du praticien_ 40.7 (1990), pp. 677-81. PMID: 2326596.
lapply(pmids[1:3], function(x){
tmp <- unlist(ReadPubMed(x, database = "PubMed", mindate = 1950))
tmp <- lapply(tmp, function(z) if(is(z, "person")) paste0(z, collapse = ",") else z)
data.frame(tmp, stringsAsFactors = FALSE)
})
title
1 Immunophenotype profile of childhood medulloblastomas and supratentorial primitive neuroectodermal tumors using 16 monoclonal antibodies
2 The influence of temperature on muscle velocity and sustained performance in swimming carp
3 [Headache, facial neuralgia. Diagnostic orientation and management]
author year journal volume number pages eprint language eprinttype bibtype
1 P M Zeltzer,B Bodey,A Marlin,J Kemshead 1990 Cancer 66 2 273-83 2196109 eng pubmed Article
2 L C Rome,R P Funke,R M Alexander 1990 The Journal of experimental biology 154 <NA> 163-78 2277258 eng pubmed Article
3 P Henry 1990 La Revue du praticien 40 7 677-81 2326596 fre pubmed Article
dateobj key
1 1990-01-01 zeltzer1990immunophenotype
2 1990-01-01 rome1990influence
3 1990-01-01 henry1990headache