File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 1- # ' Fetch Europe PMC full texts
1+ # ' Fetch Europe PMC full text
22# '
3- # ' This function loads full texts into R. Full texts are in XML format and are
3+ # ' This function loads one full text into R. Full text is in XML format and is
44# ' only provided for the Open Access subset of Europe PMC.
55# '
66# ' @param ext_id character, PMCID.
1515# ' epmc_ftxt("PMC3639880")
1616# ' }
1717epmc_ftxt <- function (ext_id = NULL ) {
18- if (! grepl(" ^PMC" , ext_id ))
19- stop(" Please provide a PMCID, i.e. ids starting with 'PMC'" )
18+ if (! grepl(" ^PMC" , ext_id ) || length( ext_id ) != 1 )
19+ stop(" Please provide one PMCID, i.e. id starting with 'PMC'" )
2020 # call api
2121 req <-
2222 httr :: RETRY(" GET" ,
Original file line number Diff line number Diff line change @@ -5,14 +5,14 @@ test_that("epmc_ftxt returns", {
55 a <- epmc_ftxt(" PMC3257301" )
66 b <- epmc_ftxt(" PMC3639880" )
77
8- # correct class metadata
8+ # correct class metadata
99 expect_is(a , " xml_document" )
1010 expect_is(b , " xml_document" )
1111
1212 # fails correctly
1313 expect_error(epmc_ftxt(" 2PMC3448176" ))
1414 expect_error(epmc_ftxt(" PMC3476" ))
1515 expect_error(epmc_ftxt(" 3476" ),
16- " Please provide a PMCID, i.e. ids starting with 'PMC'"
17- )
16+ " Please provide one PMCID, i.e. id starting with 'PMC'"
17+ )
1818})
You can’t perform that action at this time.
0 commit comments