DownloadXMLWithPmidsBatch: #' DownloadJsonWithPmidsBatch #' #' @param pmids a string of...

Description Usage Arguments Value Examples

View source: R/pubmedRead.R

Description

#' DownloadJsonWithPmidsBatch #' #' @param pmids a string of character. PubMed central Id #' @param apiKey a string of characters. The API Key obtained through NCBI account #' @param endpoint a string of characters. The API endpoint to use. e.g. "esummary", "efetch" #' @param fileBaseName a string of character. The base name of the to be saved xml files #' #' @return the output file names #' @export #' #' @examples DownloadJsonWithPmidsBatch(c("28852052", "29041955"), endpoint = "efetch", fileBaseName="test.json") #' #' @import jsonlite #' DownloadJsonWithPmidsBatch <- function(pmids, apiKey = "", endpoint = "efetch", fileBaseName = "test.json") db <- "pubmed" nids <- length(pmids) grid <- 500 nloop <- ceiling(nids / grid) outputFiles <- matrix("", nrow=nloop) for (iloop in 1:nloop) iindex <- (((iloop - 1) * grid) + 1) : ifelse(iloop * grid > nids, nids, iloop * grid)

result_josn <- GetJson(id =pmids[iindex], db = db, endpoint = endpoint, apiKey = apiKey)

outputFile <- jsonlite::write_json(result_josn, path = paste0( gsub("[.]json", "", fileBaseName), min(iindex), "_", max(iindex), ".json" )) outputFiles[iloop] <- outputFile return(outputFiles) DownloadXMLWithPmidsBatch

Usage

1
2
3
4
5
6
DownloadXMLWithPmidsBatch(
  pmids,
  apiKey = "",
  endpoint = "esummary",
  fileBaseName = "test.xml"
)

Arguments

pmids

a string of character. PubMed central Id

apiKey

a string of characters. The API Key obtained through NCBI account

endpoint

a string of characters. The API endpoint to use. e.g. "esummary", "efetch"

fileBaseName

a string of character. The base name of the to be saved xml files

Value

the output file names

Examples

1
DownloadXMLWithPmidsBatch(c("28852052", "29041955"), endpoint = "efetch", fileBaseName="test.xml")

shihikoo/pubmedTools documentation built on Oct. 12, 2020, 12:52 p.m.