Skip to content

Instantly share code, notes, and snippets.

@dhicks
Created January 12, 2018 21:44
Show Gist options
  • Save dhicks/40905a2efe1224592357a9e83b905baa to your computer and use it in GitHub Desktop.
Save dhicks/40905a2efe1224592357a9e83b905baa to your computer and use it in GitHub Desktop.
Extract grant IDs and funding information from PubMed records
library(rentrez)
library(magrittr)
library(xml2)
xml_raw = entrez_fetch(db="pubmed",
id=27019001,
rettype = 'xml')
xml_parsed = read_xml(xml_raw)
grant_id = xml_find_all(xml_parsed, '//Grant') %>%
xml_find_first('GrantID') %>%
xml_text()
funding_agency = xml_find_all(xml_parsed, '//Grant') %>%
xml_find_first('Agency') %>%
xml_text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment