ropensci / europepmc

R Interface to Europe PMC RESTful Web Service
https://docs.ropensci.org/europepmc
27 stars 8 forks source link

Update empc_ftxt() to indicate 1 input limit #55

Closed allenbaron closed 7 months ago

allenbaron commented 8 months ago

epmc_ftxt() only works with one PMCID. Currently, it attempts to execute with more than one PMCID and fails. In the example below 2 good PMCIDs are passed, first together then separately. Only when they are given separately does it work.

library(europepmc)

pmcids <- c("PMC10341083", "PMC10297282")
res1 <- epmc_ftxt(pmcids)
#> Warning in if (!grepl("^PMC", ext_id)) stop("Please provide a PMCID, i.e. ids
#> starting with 'PMC'"): the condition has length > 1 and only the first element
#> will be used
#> Request failed [404]. Retrying in 1 seconds...
#> Request failed [404]. Retrying in 4 seconds...
#> Error in epmc_ftxt(pmcids): Not Found (HTTP 404). Failed to retrieve full text..

res2 <- lapply(pmcids, epmc_ftxt)
length(res2)
#> [1] 2

Created on 2023-11-17 by the reprex package (v2.0.1)

The current documentation appears to indicate epmc_ftxt() can accept multiple inputs and the test to ensure ext_id is correctly formatted will pass as long as the first element of ext_id starts with 'PMC' (all others are ignored with a warning).

This PR depluralizes the documentation and updates the ext_id argument test to ensure it allows only one PMCID. Loosely related to #38 and #37.

It seems like the documentation for europepmc functions are written in plural while primarily accepting singular inputs, so I totally understand if the documentation updates are dropped. The ext_id test update alone would still avoid malformed API requests and the need for user debugging.

njahn82 commented 7 months ago

Looks good, thanks for improving the documentation and input control; it was very confusing indeed.