答案 0 :(得分:0)
这可能有效
library(easyPubMed)
library(purrr)
Query <- c('rituximab OR bevacizumab','meningitis OR headache')
Heading <- c('A','B')
x <- as.data.frame(cbind(Heading,Query),stringsAsFactors = F)
x$PMID<- ""
ids <- map(x[,"Query"],get_pubmed_ids)
for (i in 1:length(ids)) {
x[i,"PMID"]<- paste(ids[[i]][["IdList"]],collapse = ",")
}
我认为“sapply”不会返回预期的结果,所以从“purrr”包中走“map”方式更安全。