Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cr_works returning error when querying some DOIs #180

Closed
nicholasmfraser opened this issue Jan 3, 2019 · 3 comments
Closed

cr_works returning error when querying some DOIs #180

nicholasmfraser opened this issue Jan 3, 2019 · 3 comments
Labels
Milestone

Comments

@nicholasmfraser
Copy link

nicholasmfraser commented Jan 3, 2019

I've encountered instances of the cr_works route failing on a very small number of DOIs, for example:

cr_works(doi="10.3389/fgene.2017.00147")

returns

Error in w[sapply(w, function(b) length(b) == 0)] <- NULL : 
  invalid subscript type 'list'

I think the problem lies in the parse_todf function in cr_works.R. When Crossref returns an empty list (in the case of the DOI record referenced above, under funder[1], see API response) the parse function fails. For now I'm using the cr_works_ low level route instead, which works fine.

Changing lines 349-350 from:

w[sapply(w, function(b) length(b) == 0)] <- NULL
data.frame(w, stringsAsFactors = FALSE)`

to

if(length(w) > 0) {
    w[sapply(w, function(b) length(b) == 0)] <- NULL
    data.frame(w, stringsAsFactors = FALSE)
}

seems to work, but I haven't tested extensively.

Session Info
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

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

other attached packages:
 [1] rcrossref_0.8.4 forcats_0.3.0   stringr_1.3.1   dplyr_0.7.6     purrr_0.2.5     readr_1.1.1     tidyr_0.8.1    
 [8] tibble_1.4.2    ggplot2_3.0.0   tidyverse_1.2.1

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.4 haven_1.1.2      lattice_0.20-35  colorspace_1.3-2 miniUI_0.1.1.1   htmltools_0.3.6  yaml_2.2.0      
 [8] utf8_1.1.4       rlang_0.3.0.1    pillar_1.3.0     later_0.7.3      httpcode_0.2.0   glue_1.3.0       withr_2.1.2     
[15] modelr_0.1.2     readxl_1.1.0     bindrcpp_0.2.2   bindr_0.1.1      plyr_1.8.4       munsell_0.5.0    gtable_0.2.0    
[22] cellranger_1.1.0 rvest_0.3.2      htmlwidgets_1.2  knitr_1.20       httpuv_1.4.5     curl_3.2         fansi_0.2.3     
[29] triebeard_0.3.0  urltools_1.7.1   broom_0.5.0      Rcpp_0.12.18     xtable_1.8-2     DT_0.4           scales_1.0.0    
[36] backports_1.1.2  promises_1.0.1   jsonlite_1.5     mime_0.5         hms_0.4.2        digest_0.6.15    stringi_1.1.7   
[43] shiny_1.1.0      bibtex_0.4.2     grid_3.5.1       cli_1.0.0        tools_3.5.1      magrittr_1.5     lazyeval_0.2.1  
[50] crul_0.6.0       crayon_1.3.4     pkgconfig_2.0.1  xml2_1.2.0       lubridate_1.7.4  assertthat_0.2.0 httr_1.3.1      
[57] rstudioapi_0.7   R6_2.2.2         nlme_3.1-137     compiler_3.5.1  
@sckott sckott added the bug label Jan 3, 2019
@sckott sckott added this to the v0.9 milestone Jan 3, 2019
@sckott
Copy link
Contributor

sckott commented Jan 3, 2019

thanks for the report @nicholasmfraser

i can replicate the issue. ill see about that change

@sckott sckott closed this as completed in a63ff8c Jan 9, 2019
@sckott
Copy link
Contributor

sckott commented Jan 9, 2019

@nicholasmfraser reinstall and try again, shoud be fixed now

@nicholasmfraser
Copy link
Author

@sckott works fine now, thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants