ropensci / europepmc

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

Can't retreive all records using epmc_search --- Error in if (page_token == out$next_cursor) break : argument is zero length #41

Closed jcbailone closed 2 years ago

jcbailone commented 2 years ago

Hello,

First of all thanks for your package.

I think there are an error when the function epmc_search try to retrieve all records. For example the next query has 39 results and when I try to get back all of then the functions fails:

            `epmc_search(query ="AUTHORID:0000-0003-1393-215X")
            39 records found, returning 39
            Error in if (page_token == out$next_cursor) break : 
             argument is zero length`

But If I set a limit lesst than the number of records the functions works:

              `epmc_search(query ="AUTHORID:0000-0003-1393-215X", limit=1)
              39 records found, returning 1
              # A tibble: 1 × 27
                id       source pmid     pmcid doi   title authorString journalTitle issue journalVolume pubYear journalIssn pubType isOpenAccess inEPMC inPMC hasPDF hasBook hasSuppl
                <chr>    <chr>  <chr>    <chr> <chr> <chr> <chr>        <chr>        <chr> <chr>         <chr>   <chr>       <chr>   <chr>        <chr>  <chr> <chr>  <chr>   <chr>   
              1 34207908 MED    34207908 PMC8… 10.3… Smar… Merazzo KJ,… Diagnostics… 6     11            2021    2075-4418   review… Y            Y      N     Y      N       N       
              # … with 8 more variables: citedByCount <int>, hasReferences <chr>, hasTextMinedTerms <chr>, hasDbCrossReferences <chr>, hasLabsLinks <chr>,
              #   hasTMAccessionNumbers <chr>, firstIndexDate <chr>, firstPublicationDate <chr>`

This is my sessionInfo:

              ` sessionInfo()
              R version 4.1.1 (2021-08-10)
              Platform: x86_64-pc-linux-gnu (64-bit)
              Running under: Ubuntu 20.04.3 LTS

              Matrix products: default
              BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
              LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

              locale:
               [1] LC_CTYPE=es_ES.UTF-8       LC_NUMERIC=C               LC_TIME=es_ES.UTF-8        LC_COLLATE=es_ES.UTF-8     LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=es_ES.UTF-8   
               [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

              attached base packages:
              [1] stats     graphics  grDevices utils     datasets  methods   base     

              other attached packages:
              [1] europepmc_0.4  RMariaDB_1.1.1

              loaded via a namespace (and not attached):
               [1] Rcpp_1.0.7        rstudioapi_0.13   xml2_1.3.2        magrittr_2.0.1    progress_1.2.2    hms_1.1.0         tidyselect_1.1.1  bit_4.0.4         R6_2.5.1         
              [10] rlang_0.4.11      fansi_0.5.0       plyr_1.8.6        httr_1.4.2        dplyr_1.0.7       tools_4.1.1       utf8_1.2.2        cli_3.0.1         DBI_1.1.1        
              [19] ellipsis_0.3.2    bit64_4.0.5       assertthat_0.2.1  tibble_3.1.4      lifecycle_1.0.0   crayon_1.4.1      tidyr_1.1.3       purrr_0.3.4       vctrs_0.3.8      
              [28] curl_4.3.2        triebeard_0.3.0   glue_1.4.2        compiler_4.1.1    pillar_1.6.2      urltools_1.7.3    prettyunits_1.1.1 generics_0.1.0    jsonlite_1.7.2   
              [37] pkgconfig_2.0.3  `

Tell me if I can do something to help. =)

njahn82 commented 2 years ago

Hi @jcbailone thank you for your report. There has been an API change recently, which is implemented in the dev version on GitHub. Please update the {europepmc} package:

remotes::install_github("ropensci/europepmc")

I'll submit this version to CRAN soon.

Here's a reprex using your example with the current dev version on GitHub:

library(europepmc)
packageVersion("europepmc")
#> [1] '0.4.1'
epmc_search(query ="AUTHORID:0000-0003-1393-215X")
#> 39 records found, returning 39
#> # A tibble: 39 × 28
#>    id       source pmid     pmcid  doi   title  authorString  journalTitle issue
#>    <chr>    <chr>  <chr>    <chr>  <chr> <chr>  <chr>         <chr>        <chr>
#>  1 34207908 MED    34207908 PMC82… 10.3… Smart… Merazzo KJ, … Diagnostics… 6    
#>  2 33427446 MED    33427446 <NA>   10.1… Detec… Sánchez-Cano… ACS Sens     1    
#>  3 29498271 MED    29498271 <NA>   10.1… NaNO<… López-Marzo … Anal Chem    6    
#>  4 26155767 MED    26155767 <NA>   10.1… Rever… Herrasti Z, … Lab Chip     16   
#>  5 24994664 MED    24994664 <NA>   10.1… Carbo… Herrasti Z, … Anal Bioana… 22   
#>  6 31817657 MED    31817657 PMC69… 10.3… Compe… Montes-Cebri… Sensors (Ba… 24   
#>  7 29254566 MED    29254566 <NA>   10.1… Using… Ben Ismail M… Anal Chim A… <NA> 
#>  8 23601924 MED    23601924 PMC36… 10.1… Fast … Bedrina B, M… BMC Microbi… <NA> 
#>  9 24482799 MED    24482799 <NA>   10.1… Elect… Herrasti Z, … Analyst      6    
#> 10 26592620 MED    26592620 <NA>   10.1… Minia… Uria N, Abra… Talanta      <NA> 
#> # … with 29 more rows, and 19 more variables: journalVolume <chr>,
#> #   pubYear <chr>, journalIssn <chr>, pubType <chr>, isOpenAccess <chr>,
#> #   inEPMC <chr>, inPMC <chr>, hasPDF <chr>, hasBook <chr>, hasSuppl <chr>,
#> #   citedByCount <int>, hasReferences <chr>, hasTextMinedTerms <chr>,
#> #   hasDbCrossReferences <chr>, hasLabsLinks <chr>,
#> #   hasTMAccessionNumbers <chr>, firstIndexDate <chr>,
#> #   firstPublicationDate <chr>, pageInfo <chr>

Created on 2021-09-01 by the reprex package (v2.0.0)

jcbailone commented 2 years ago

Thank you for answering so quickly, now is working fine!!