Learn R Programming

pubmedtk (version 1.0.4)

get_metadata_from_pmids: Downloads metadata from Pubmed API for a column of PMID's in a data frame

Description

Downloads metadata from Pubmed API for a column of PMID's in a data frame

Usage

get_metadata_from_pmids(df, column, api_key, quiet = FALSE)

Value

A data frame containing the original columns as well as seven additional columns:

The `pubmed_dl_success` column is TRUE in the case that
metadata were successfully downloaded from Pubmed; FALSE in the
case that an error occurred during downloading (e.g. due to a
number that is well-formed but does not correspond to a true
PMID); NA in the case that the supplied PMID is not well-formed
(e.g. NA or non-numeric).

The `doi` column returns a DOI that corresponds to the PMID supplied if one is found, NA otherwise.

The `languages` column contains a JSON-encoded list of languages for the article in question.

The `pubtypes` column contains a JSON-encoded list of publication types for the article in question.

The `pubdate` column contains a character string with the publication date

The `epubdate` column contains a character string with the e-publication date

The `authors` column contains a JSON-encoded list of authors for the article in question.

The `abstract` column contains a character string with the abstract for the article in question.

Arguments

df

A dataframe containing a column of PMID's

column

The name of the column containing PMID's

api_key

A valid Pubmed API key

quiet

A boolean TRUE or FALSE. If TRUE, no progress messages will be printed during download. FALSE by default, messages printed for every version downloaded showing progress.

Examples

Run this code

if (FALSE) {
## Read in API key
ak <- readLines("api_key.txt")

## Example publications and their corresponding PMID's (some valid
## and some not)
pubs <- tibble::tribble(
  ~pmid,
  "29559429",
  "28837722",
  NA,
  "borp",
  "98472657638729"
)

## Download Pubmed metadata
pm_meta <- get_metadata_from_pmids(pubs, "pmid", ak)

## Extract DOI's for those that were successfully downloaded
pm_meta %>%
  dplyr::filter(pubmed_dl_success)
  dplyr::select(pmid, doi)

## A tibble: 2 × 2
##   pmid     doi                    
##                         
## 1 29559429 10.1136/bmj.k959       
## 2 28837722 10.1001/jama.2017.11502

}

Run the code above in your browser using DataLab