ropensci/rcrossref

preventing NULL output (w/ (504) warning)

lukasjonkers opened this issue · 1 comments

Session Info
Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.1 (2019-07-05)
 os       macOS High Sierra 10.13.6   
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_GB.UTF-8                 
 ctype    en_GB.UTF-8                 
 tz       Europe/Berlin               
 date     2019-10-15Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source        
 assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.6.0)
 backports     1.1.5   2019-10-02 [1] CRAN (R 3.6.0)
 bibtex        0.4.2   2017-06-30 [1] CRAN (R 3.6.0)
 broom         0.5.2   2019-04-07 [1] CRAN (R 3.6.0)
 callr         3.3.2   2019-09-22 [1] CRAN (R 3.6.0)
 cellranger    1.1.0   2016-07-27 [1] CRAN (R 3.6.0)
 cli           1.1.0   2019-03-19 [1] CRAN (R 3.6.0)
 colorspace    1.4-1   2019-03-18 [1] CRAN (R 3.6.0)
 crayon        1.3.4   2017-09-16 [1] CRAN (R 3.6.0)
 crul          0.8.4   2019-08-02 [1] CRAN (R 3.6.0)
 curl          4.2     2019-09-24 [1] CRAN (R 3.6.0)
 desc          1.2.0   2018-05-01 [1] CRAN (R 3.6.0)
 devtools      2.2.1   2019-09-24 [1] CRAN (R 3.6.0)
 digest        0.6.21  2019-09-20 [1] CRAN (R 3.6.0)
 dplyr       * 0.8.3   2019-07-04 [1] CRAN (R 3.6.0)
 DT            0.9     2019-09-17 [1] CRAN (R 3.6.0)
 ellipsis      0.3.0   2019-09-20 [1] CRAN (R 3.6.0)
 fastmap       1.0.1   2019-10-08 [1] CRAN (R 3.6.0)
 forcats     * 0.4.0   2019-02-17 [1] CRAN (R 3.6.0)
 fs            1.3.1   2019-05-06 [1] CRAN (R 3.6.0)
 generics      0.0.2   2018-11-29 [1] CRAN (R 3.6.0)
 ggplot2     * 3.2.1   2019-08-10 [1] CRAN (R 3.6.0)
 glue          1.3.1   2019-03-12 [1] CRAN (R 3.6.0)
 gtable        0.3.0   2019-03-25 [1] CRAN (R 3.6.0)
 haven         2.1.1   2019-07-04 [1] CRAN (R 3.6.0)
 hms           0.5.1   2019-08-23 [1] CRAN (R 3.6.0)
 htmltools     0.4.0   2019-10-04 [1] CRAN (R 3.6.0)
 htmlwidgets   1.5.1   2019-10-08 [1] CRAN (R 3.6.0)
 httpcode      0.2.0   2016-11-14 [1] CRAN (R 3.6.0)
 httpuv        1.5.2   2019-09-11 [1] CRAN (R 3.6.0)
 httr          1.4.1   2019-08-05 [1] CRAN (R 3.6.0)
 jsonlite      1.6     2018-12-07 [1] CRAN (R 3.6.0)
 later         1.0.0   2019-10-04 [1] CRAN (R 3.6.0)
 lattice       0.20-38 2018-11-04 [1] CRAN (R 3.6.1)
 lazyeval      0.2.2   2019-03-15 [1] CRAN (R 3.6.0)
 lifecycle     0.1.0   2019-08-01 [1] CRAN (R 3.6.0)
 lubridate     1.7.4   2018-04-11 [1] CRAN (R 3.6.0)
 magrittr      1.5     2014-11-22 [1] CRAN (R 3.6.0)
 memoise       1.1.0   2017-04-21 [1] CRAN (R 3.6.0)
 mime          0.7     2019-06-11 [1] CRAN (R 3.6.0)
 miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 3.6.0)
 modelr        0.1.5   2019-08-08 [1] CRAN (R 3.6.0)
 munsell       0.5.0   2018-06-12 [1] CRAN (R 3.6.0)
 nlme          3.1-141 2019-08-01 [1] CRAN (R 3.6.0)
 pillar        1.4.2   2019-06-29 [1] CRAN (R 3.6.0)
 pkgbuild      1.0.6   2019-10-09 [1] CRAN (R 3.6.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 3.6.0)
 pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.6.0)
 plyr          1.8.4   2016-06-08 [1] CRAN (R 3.6.0)
 prettyunits   1.0.2   2015-07-13 [1] CRAN (R 3.6.0)
 processx      3.4.1   2019-07-18 [1] CRAN (R 3.6.0)
 promises      1.1.0   2019-10-04 [1] CRAN (R 3.6.0)
 ps            1.3.0   2018-12-21 [1] CRAN (R 3.6.0)
 purrr       * 0.3.2   2019-03-15 [1] CRAN (R 3.6.0)
 R6            2.4.0   2019-02-14 [1] CRAN (R 3.6.0)
 Rcpp          1.0.2   2019-07-25 [1] CRAN (R 3.6.0)
 rcrossref   * 0.9.2   2019-05-04 [1] CRAN (R 3.6.0)
 readr       * 1.3.1   2018-12-21 [1] CRAN (R 3.6.0)
 readxl        1.3.1   2019-03-13 [1] CRAN (R 3.6.0)
 remotes       2.1.0   2019-06-24 [1] CRAN (R 3.6.0)
 rlang         0.4.0   2019-06-25 [1] CRAN (R 3.6.0)
 rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.6.0)
 rstudioapi    0.10    2019-03-19 [1] CRAN (R 3.6.0)
 rvest         0.3.4   2019-05-15 [1] CRAN (R 3.6.0)
 scales        1.0.0   2018-08-09 [1] CRAN (R 3.6.0)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.6.0)
 shiny         1.4.0   2019-10-10 [1] CRAN (R 3.6.0)
 stringi       1.4.3   2019-03-12 [1] CRAN (R 3.6.0)
 stringr     * 1.4.0   2019-02-10 [1] CRAN (R 3.6.0)
 testthat      2.2.1   2019-07-25 [1] CRAN (R 3.6.0)
 tibble      * 2.1.3   2019-06-06 [1] CRAN (R 3.6.0)
 tidyr       * 1.0.0   2019-09-11 [1] CRAN (R 3.6.0)
 tidyselect    0.2.5   2018-10-11 [1] CRAN (R 3.6.0)
 tidyverse   * 1.2.1   2017-11-14 [1] CRAN (R 3.6.0)
 triebeard     0.3.0   2016-08-04 [1] CRAN (R 3.6.0)
 urltools      1.7.3   2019-04-14 [1] CRAN (R 3.6.0)
 usethis       1.5.1   2019-07-04 [1] CRAN (R 3.6.0)
 vctrs         0.2.0   2019-07-05 [1] CRAN (R 3.6.0)
 withr         2.1.2   2018-03-15 [1] CRAN (R 3.6.0)
 xml2          1.2.2   2019-08-09 [1] CRAN (R 3.6.0)
 xtable        1.8-4   2019-04-21 [1] CRAN (R 3.6.0)
 zeallot       0.1.0   2018-01-28 [1] CRAN (R 3.6.0)

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

cr_cn sometimes returns NULL and gives a w/ (504) warning. Any suggestions how I can prevent this and get a citation?


dois <- cr_r(2)
dois
[1] "10.1111/an.2000.41.5.33"      "10.1007/978-3-319-28932-8_38"
cr_cn(dois, 'text', 'apa')
[[1]]
NULL

[[2]]
[1] "Ergon, Å., Solem, S., Uhlen, A. K., & Bakken, A. K. (2016). Generative Development in Red Clover in Response to Temperature and Photoperiod. Breeding in a World of Scarcity, 243–247. doi:10.1007/978-3-319-28932-8_38"

Warning message:
10.1111/an.2000.41.5.33 w/ (504) - 

thanks for your question @lukasjonkers

The 504 indicates a server error, an error from doi.org. It's likely that was just a temporary problem for doi.org since it works now. When that does happen, you can just try again. If you want this programatically, you could have a check for any NULL outputs and then retry those DOIs.

We could fail on a failure like that 504 so that it stops on the one that failed, but then any failure would stop the progress of the other DOIs.

Does that help?