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

wm_attr_data_() Error: (204) No content #14

Closed
AAlines opened this issue Aug 23, 2018 · 14 comments · Fixed by #18
Closed

wm_attr_data_() Error: (204) No content #14

AAlines opened this issue Aug 23, 2018 · 14 comments · Fixed by #18
Milestone

Comments

@AAlines
Copy link

AAlines commented Aug 23, 2018

Session Info
Session info ---------------------------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.2 (2017-09-28)
 system   i386, mingw32               
 ui       RStudio (1.1.383)           
 language (EN)                        
 collate  English_United Kingdom.1252 
 tz       Europe/London               
 date     2018-08-23                  

Packages -------------------------------------------------------------------------------------------------------------------------------------------------------------------
 package    * version  date       source        
 assertthat   0.2.0    2017-04-11 CRAN (R 3.4.2)
 backports    1.1.1    2017-09-25 CRAN (R 3.4.1)
 base       * 3.4.2    2017-09-28 local         
 base64enc    0.1-3    2015-07-28 CRAN (R 3.4.1)
 bindr        0.1      2016-11-13 CRAN (R 3.4.2)
 bindrcpp   * 0.2      2017-06-17 CRAN (R 3.4.2)
 broom        0.4.3    2017-11-20 CRAN (R 3.4.3)
 cellranger   1.1.0    2016-07-27 CRAN (R 3.4.2)
 cli          1.0.0    2017-11-05 CRAN (R 3.4.2)
 colorspace   1.3-2    2016-12-14 CRAN (R 3.4.2)
 compiler     3.4.2    2017-09-28 local         
 crayon       1.3.4    2017-09-16 CRAN (R 3.4.2)
 crul         0.6.0    2018-07-10 CRAN (R 3.4.4)
 curl         3.2      2018-03-28 CRAN (R 3.4.4)
 data.table   1.10.4-3 2017-10-27 CRAN (R 3.4.4)
 datasets   * 3.4.2    2017-09-28 local         
 devtools     1.13.6   2018-06-27 CRAN (R 3.4.4)
 digest       0.6.12   2017-01-27 CRAN (R 3.4.2)
 dplyr      * 0.7.4    2017-09-28 CRAN (R 3.4.2)
 evaluate     0.10.1   2017-06-24 CRAN (R 3.4.2)
 forcats    * 0.2.0    2017-01-23 CRAN (R 3.4.2)
 foreign      0.8-69   2017-06-22 CRAN (R 3.4.2)
 ggplot2    * 3.0.0    2018-07-03 CRAN (R 3.4.4)
 glue         1.2.0    2017-10-29 CRAN (R 3.4.2)
 graphics   * 3.4.2    2017-09-28 local         
 grDevices  * 3.4.2    2017-09-28 local         
 grid         3.4.2    2017-09-28 local         
 gtable       0.2.0    2016-02-26 CRAN (R 3.4.2)
 haven        1.1.0    2017-07-09 CRAN (R 3.4.2)
 hms          0.4.0    2017-11-23 CRAN (R 3.4.2)
 htmltools    0.3.6    2017-04-28 CRAN (R 3.4.2)
 httpcode     0.2.0    2016-11-14 CRAN (R 3.4.1)
 httr         1.3.1    2017-08-20 CRAN (R 3.4.2)
 jsonlite     1.5      2017-06-01 CRAN (R 3.4.2)
 knitr        1.17     2017-08-10 CRAN (R 3.4.2)
 lattice      0.20-35  2017-03-25 CRAN (R 3.4.2)
 lazyeval     0.2.1    2017-10-29 CRAN (R 3.4.2)
 lubridate    1.7.4    2018-04-11 CRAN (R 3.4.4)
 magrittr     1.5      2014-11-22 CRAN (R 3.4.2)
 memoise      1.1.0    2017-04-21 CRAN (R 3.4.4)
 methods    * 3.4.2    2017-09-28 local         
 mnormt       1.5-5    2016-10-15 CRAN (R 3.4.1)
 modelr       0.1.1    2017-07-24 CRAN (R 3.4.2)
 munsell      0.4.3    2016-02-13 CRAN (R 3.4.2)
 nlme         3.1-131  2017-02-06 CRAN (R 3.4.2)
 parallel     3.4.2    2017-09-28 local         
 pkgconfig    2.0.1    2017-03-21 CRAN (R 3.4.2)
 plyr         1.8.4    2016-06-08 CRAN (R 3.4.2)
 psych        1.7.8    2017-09-09 CRAN (R 3.4.2)
 purrr      * 0.2.4    2017-10-18 CRAN (R 3.4.2)
 R6           2.2.2    2017-06-17 CRAN (R 3.4.2)
 Rcpp         0.12.14  2017-11-23 CRAN (R 3.4.2)
 readr      * 1.1.1    2017-05-16 CRAN (R 3.4.2)
 readxl       1.0.0    2017-04-18 CRAN (R 3.4.2)
 reshape2     1.4.2    2016-10-22 CRAN (R 3.4.2)
 rlang        0.2.0    2018-02-20 CRAN (R 3.4.3)
 rmarkdown    1.8      2017-11-17 CRAN (R 3.4.2)
 rprojroot    1.2      2017-01-16 CRAN (R 3.4.2)
 rstudioapi   0.7      2017-09-07 CRAN (R 3.4.2)
 rvest        0.3.2    2016-06-17 CRAN (R 3.4.2)
 scales       0.5.0    2017-08-24 CRAN (R 3.4.2)
 stats      * 3.4.2    2017-09-28 local         
 stringi      1.1.6    2017-11-17 CRAN (R 3.4.2)
 stringr    * 1.2.0    2017-02-18 CRAN (R 3.4.2)
 tibble     * 1.3.4    2017-08-22 CRAN (R 3.4.2)
 tidyr      * 0.7.2    2017-10-16 CRAN (R 3.4.2)
 tidyverse  * 1.2.1    2017-11-14 CRAN (R 3.4.4)
 tools        3.4.2    2017-09-28 local         
 triebeard    0.3.0    2016-08-04 CRAN (R 3.4.4)
 urltools     1.7.1    2018-08-03 CRAN (R 3.4.4)
 utils      * 3.4.2    2017-09-28 local         
 withr        2.1.2    2018-03-15 CRAN (R 3.4.4)
 worrms     * 0.2.8    2018-05-21 CRAN (R 3.4.4)
 xml2         1.1.1    2017-01-24 CRAN (R 3.4.2)
 yaml         2.2.0    2018-07-25 CRAN (R 3.4.4)

I am trying to get species attribute information using the wm_attr_data_() function for multiple species. However, I am encountering problems when the list of AphiaID's I provide involves an AphiaID of a species with no attribute data at all on the WoRMs page for the particular species.
For example, Here the wm_attr_data_() function works for these 3 species because they all have some attribute data:

library(tidyverse)
library(worrms)
AphiaID <- c(584932, 107381, 126436)
wm_attr_data_(AphiaID, include_inherited = TRUE)

Whereas, when the AphiaID 100373 is added (A species with no attribute data on the WoRMs webpage: http://www.marinespecies.org/aphia.php?p=taxdetails&id=100373) and the following code is used:

AphiaID2 <- c(584932, 107381, 126436, 100373)
wm_attr_data_(AphiaID2, include_inherited = TRUE)

It now returns Error: (204) No Content and does not return any information for the 3 original species.

As I am planning to run this across a much larger set of species. It would perhaps be more useful if it returned the same output as the original example but with a row for the species without attribute information, with NA in each of the attribute fields, so as to avoid the function stopping.

Any advice would be appreciated.
Thanks

@sckott sckott added this to the v0.3 milestone Aug 23, 2018
@sckott
Copy link
Contributor

sckott commented Aug 23, 2018

thanks @AAlines !

having a look

@hannahmunro
Copy link

hannahmunro commented Oct 25, 2018

I think I have a solution using tryCatch(). It needs to be looped using sapply() and cleaned up but it works for me. It is not a perfect solution but might work int he short term.

AphiaID2 <- c(584932, 107381, 126436, 100373)
y<-sapply(AphiaID2,function(i) {tryCatch(wm_attr_data(i), error=function(e) print(i))})
##Cleaning up the list of lists
good<-sapply(y,is.list)
z<-y[good]
all_attributes<-bind_rows(z)

@sckott
Copy link
Contributor

sckott commented Oct 25, 2018

nice one @hannahmunro - I have been working on something, but I had a vacation and conference, so sorry for my slow response @AAlines

sckott added a commit that referenced this issue Oct 25, 2018
@sckott
Copy link
Contributor

sckott commented Oct 25, 2018

@AAlines @hannahmunro try again after reinstalling remotes::install_github("ropensci/worrms@error-vehavior")

(the error-vehavior is not a typo - i spelled it wrong when i created the branch, so we're stuck with that )

@hannahmunro
Copy link

@sckott I have tried reinstalling but I am still getting the error.

@sckott
Copy link
Contributor

sckott commented Oct 25, 2018

did you install exactly like remotes::install_github("ropensci/worrms@error-vehavior") and restart your R session?

@hannahmunro
Copy link

Works!! I realize now that I didn't restart session, rookie mistake.

I get similar errors when using some of the other functions. Do intend to institute a fix for those other functions too?

@sckott
Copy link
Contributor

sckott commented Oct 25, 2018

can you say which fxn(s)

the way I set it up, the underscore functions have the new behavior as those functions can accept many inputs, but the non-underscore version of the same function name still has the stop on error behavior as it's only meant to deal with 1 input at a time.

@hannahmunro
Copy link

I did not realize that you had implemented it for other functions. The ones that I was thinking of have been fixed! Thank you so much for your fix.

@sckott
Copy link
Contributor

sckott commented Oct 25, 2018

great

@sckott
Copy link
Contributor

sckott commented Oct 25, 2018

@AAlines does this work for you now?

@AAlines
Copy link
Author

AAlines commented Nov 1, 2018

@sckott yes this works for me now.

@sckott
Copy link
Contributor

sckott commented Nov 1, 2018

thanks

@sckott
Copy link
Contributor

sckott commented Nov 1, 2018

done

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

Successfully merging a pull request may close this issue.

3 participants