This function converts a vector of PubMed IDs (PMIDs) to their corresponding PubMed Central (PMC) IDs and DOIs using the NCBI ID Converter API.
pmid_to_pmc(pmids, batch_size = 200L, sleep = 0.5)A character or numeric vector of PubMed IDs (PMIDs) to convert.
An integer specifying the number of PMIDs to process per batch. Defaults to 200L. The NCBI API has limitations on batch sizes.
A numeric value specifying the number of seconds to pause between API requests. Defaults to 0.5 seconds to respect API rate limits.
A data.table with columns:
pmid: The input PubMed ID
pmcid: The corresponding PMC ID (NA if not available in PMC)
doi: The corresponding DOI (NA if not available)
Results are ordered by PMID. Returns NULL with a message if the API is unavailable or returns invalid data.
# \donttest{
if (interactive()) {
# Convert a single PMID to PMC ID
result <- pmid_to_pmc("12345678")
# Convert multiple PMIDs
pmids <- c("12345678", "23456789", "34567890")
result <- pmid_to_pmc(pmids, batch_size = 10, sleep = 1)
}
# }