Skip to content

Instantly share code, notes, and snippets.

@AWKruijt
Last active March 21, 2019 21:57
Show Gist options
  • Select an option

  • Save AWKruijt/96f3feef995e69ceed6901f70c1eeb5e to your computer and use it in GitHub Desktop.

Select an option

Save AWKruijt/96f3feef995e69ceed6901f70c1eeb5e to your computer and use it in GitHub Desktop.
quickly whipped up something to fetch citing articles from pubmed
# essentially same as before but now restructured into a function: getCitingPMIDs()
getCitingPMIDs <- function(PMID) {
lines <- readLines(paste0("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?dbfrom=pubmed&linkname=pubmed_pubmed_citedin&id=", PMID)) # construct quering URL using the PMID parameter in resTargetRecord, and fetch its contents into object lines
citingPMIDs <- sub("^.*(<Id>)(.*)(</Id>)", "\\2", lines[grep("<Id>", lines)]) # filter out lines in lines that contain <Id> and then filter out the content between <Id> and </Id>.Store in object citingPMIDs
citingPMIDs <- citingPMIDs[-1] # remove first entry in citingPMIDs, which is the target record
return(citingPMIDs)
}
library(RISmed)
resTarget <- EUtilsSummary("10.1371/journal.pone.0166600") # search for your target record (here I used one of my own articled search for by DOI)
resTarget@PMID # the target records PMID is in resTarget@PMID
citingPMIDs <- getCitingPMIDs(resTarget@PMID)
resCitingRecords <- EUtilsGet(citingPMIDs) # feed citingPMIDs into EUtilsGet to receive their records
resCitingRecords@ArticleTitle # titles of citing articles
@AWKruijt
Copy link
Author

annotated it somewhat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment