Code Monkey home page Code Monkey logo

worrms's Introduction

rOpenSci

Project Status: Abandoned

This repository has been archived. The former README is now in README-NOT.md.

worrms's People

Contributors

bart-v avatar jeroen avatar maelle avatar pieterprovoost avatar salvafern avatar sckott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

worrms's Issues

wm_records_name() throws an error upon unavailable name

worrms::wm_records_name(name = "Kahihi", marine_only = FALSE, 
    offset = 5)
#> Error: (204) No Content - Kahihi

Created on 2022-06-17 by the reprex package (v2.0.1)

Session Info
 version  R version 4.2.0 (2022-04-22 ucrt)
 os       Windows 10 x64 (build 22000)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/Los_Angeles
 date     2022-06-17
 rstudio  2022.02.3+492 Prairie Trillium (desktop)
 pandoc   NAPackages ───────────────────────────────────────────
 package     * version date (UTC) lib source
 brio          1.1.3   2021-11-30 [1] CRAN (R 4.2.0)
 cachem        1.0.6   2021-08-19 [1] CRAN (R 4.2.0)
 callr         3.7.0   2021-04-20 [1] CRAN (R 4.2.0)
 cli           3.3.0   2022-04-25 [1] CRAN (R 4.2.0)
 crayon        1.5.1   2022-03-26 [1] CRAN (R 4.2.0)
 crul          1.2.0   2021-11-22 [1] CRAN (R 4.2.0)
 curl        * 4.3.2   2021-06-23 [1] CRAN (R 4.2.0)
 desc          1.4.1   2022-03-06 [1] CRAN (R 4.2.0)
 devtools      2.4.3   2021-11-30 [1] CRAN (R 4.2.0)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.2.0)
 fansi         1.0.3   2022-03-24 [1] CRAN (R 4.2.0)
 fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.2.0)
 fs            1.5.2   2021-12-08 [1] CRAN (R 4.2.0)
 glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.0)
 httpcode      0.3.0   2020-04-10 [1] CRAN (R 4.2.0)
 jsonlite    * 1.8.0   2022-02-22 [1] CRAN (R 4.2.0)
 lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.2.0)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.0)
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.2.0)
 pillar        1.7.0   2022-02-01 [1] CRAN (R 4.2.0)
 pkgbuild      1.3.1   2021-12-20 [1] CRAN (R 4.2.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.2.0)
 pkgload       1.2.4   2021-11-30 [1] CRAN (R 4.2.0)
 prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.2.0)
 processx      3.5.3   2022-03-25 [1] CRAN (R 4.2.0)
 ps            1.7.0   2022-04-23 [1] CRAN (R 4.2.0)
 purrr         0.3.4   2020-04-17 [1] CRAN (R 4.2.0)
 R6            2.5.1   2021-08-19 [1] CRAN (R 4.2.0)
 Rcpp          1.0.8.3 2022-03-17 [1] CRAN (R 4.2.0)
 remotes       2.4.2   2021-11-30 [1] CRAN (R 4.2.0)
 rlang         1.0.2   2022-03-04 [1] CRAN (R 4.2.0)
 rprojroot     2.0.3   2022-04-02 [1] CRAN (R 4.2.0)
 rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.2.0)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.0)
 testthat      3.1.4   2022-04-26 [1] CRAN (R 4.2.0)
 tibble        3.1.7   2022-05-03 [1] CRAN (R 4.2.0)
 triebeard     0.3.0   2016-08-04 [1] CRAN (R 4.2.0)
 urltools      1.7.3   2019-04-14 [1] CRAN (R 4.2.0)
 usethis       2.1.6   2022-05-25 [1] CRAN (R 4.2.0)
 utf8          1.2.2   2021-07-24 [1] CRAN (R 4.2.0)
 vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.2.0)
 withr         2.5.0   2022-03-03 [1] CRAN (R 4.2.0)
 worrms      * 0.4.3   2022-06-18 [1] local

Atttribute data not returned both with wm_attr_data and wm_attr_data_

Hello,

I am running worrms version 0.4.2 in R version 4.1.1 and I have an issue retrieving attribute data.

a) I am trying to retrieve attributes using a list of AphiaIDs and even though there are attribute data for the species in WoRMS, I get error messages for no content.

wm_attr_data_(id = c(254879, 212885, 273697, 273699, 273700, 212870, 159288, 212878, 159289, 212888))

Warning messages: 1: (404) Not Found - 254879 2: (404) Not Found - 212885 3: (404) Not Found - 273697 4: (404) Not Found - 273699 5: (404) Not Found - 273700 6: (404) Not Found - 212870 7: (404) Not Found - 159288 8: (404) Not Found - 212878 9: (404) Not Found - 159289 10: (404) Not Found - 212888
At first, I thought I had the same issue with #14

So, I tried installing
remotes::install_github("ropensci/worrms@error-vehavior")
to solve the issue

but I got the error

Downloading GitHub repo ropensci/worrms@error-vehavior Error in utils::download.file(url, path, method = method, quiet = quiet, : cannot open URL 'https://api.github.com/repos/ropensci/worrms/tarball/error-vehavior'

When I tried retrieving the attributes for each AphiaID individually, again I got nothing.

`

wm_attr_data(id = 254879)
Error: (404) Not Found - 254879
wm_attr_data(id = 212885)
Error: (404) Not Found - 212885
wm_attr_data(id = 273697)
Error: (404) Not Found - 273697
wm_attr_data(id = 273699)
Error: (404) Not Found - 273699
wm_attr_data(id = 273700)
Error: (404) Not Found - 273700
wm_attr_data(id = 212870)
Error: (404) Not Found - 212870
wm_attr_data(id = 159288)
Error: (404) Not Found - 159288
wm_attr_data(id = 212878)
Error: (404) Not Found - 212878
wm_attr_data(id = 159289)
Error: (404) Not Found - 159289
wm_attr_data(id = 212888)
Error: (404) Not Found - 212888`

b) This is just a small example of my dataset... My original dataset is 4681 AphiaIDs for which, apart from the error I mentioned above, I get another one
Error: lexical error: invalid char in json text. <html><body><h1>429 Too Many Re (right here) ------^
I thought it was because my list was too big, but I got the lexical error even when I subset the dataset in chunks of 1000.

Do you have any idea what might be wrong?

Session Info
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=Greek_Greece.1253  LC_CTYPE=Greek_Greece.1253    LC_MONETARY=Greek_Greece.1253
[4] LC_NUMERIC=C                  LC_TIME=Greek_Greece.1253    

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

other attached packages:
 [1] rfishbase_4.1.2  leaflet_2.1.2    sf_1.0-13        mregions_0.1.8   obistools_0.0.10
 [6] worms_1.0.1      plyr_1.8.8       httr_1.4.6       forcats_1.0.0    stringr_1.5.0   
[11] dplyr_1.1.1      purrr_1.0.1      readr_2.1.4      tidyr_1.3.0      tibble_3.2.1    
[16] ggplot2_3.4.2    tidyverse_1.3.1  worrms_0.4.2    

loaded via a namespace (and not attached):
 [1] jsonlite_1.8.4     modelr_0.1.8       assertthat_0.2.1   triebeard_0.4.1   
 [5] urltools_1.7.3     sp_1.6-0           cellranger_1.1.0   remotes_2.4.2     
 [9] progress_1.2.2     pillar_1.9.0       backports_1.4.1    lattice_0.20-45   
[13] glue_1.6.2         digest_0.6.31      rvest_1.0.2        colorspace_2.1-0  
[17] htmltools_0.5.5    pkgconfig_2.0.3    httpcode_0.3.0     broom_0.8.0       
[21] haven_2.5.2        scales_1.2.1       tzdb_0.3.0         proxy_0.4-27      
[25] generics_0.1.3     withr_2.5.0        cli_3.6.1          magrittr_2.0.3    
[29] crayon_1.5.2       readxl_1.4.2       evaluate_0.21      data.tree_1.0.0   
[33] fs_1.5.2           fansi_1.0.4        xml2_1.3.3         class_7.3-20      
[37] data.table_1.14.8  tools_4.1.1        prettyunits_1.1.1  hms_1.1.3         
[41] geosphere_1.5-18   lifecycle_1.0.3    munsell_0.5.0      reprex_2.0.1      
[45] compiler_4.1.1     e1071_1.7-13       rlang_1.1.0        classInt_0.4-9    
[49] units_0.8-1        grid_4.1.1         rstudioapi_0.13    rappdirs_0.3.3    
[53] htmlwidgets_1.6.2  crosstalk_1.2.0    rmarkdown_2.21     gtable_0.3.3      
[57] DBI_1.1.3          curl_4.3.2         R6_2.5.1           lubridate_1.8.0   
[61] knitr_1.43         fastmap_1.1.0      rgeos_0.6-2        utf8_1.2.3        
[65] KernSmooth_2.23-20 stringi_1.7.12     crul_1.4.0         Rcpp_1.0.10       
[69] vctrs_0.6.1        dbplyr_2.2.1       tidyselect_1.2.0   xfun_0.39         

Missing standardization of field names returned by `wm_records_taxamatch()`

It seems that the names of the slots returned by wm_records_taxamatch() are not standardized: some fields are camelCase (taxonRankID, isMarine), other ones are snake_case (e.g. valid_name, valid_authority, match_type), other ones a mix of both (valid_AphiaID) and other ones no case at all (scientificname, unacceptreason).

In my opinion, following one standard is highly recommended. I would suggest to use camelCase as Darwine Core does.

library(worrms)
#> Warning: package 'worrms' was built under R version 4.2.1
taxon <- wm_records_taxamatch(name = "Halichoerus grypus")
names(taxon[[1]])
#>  [1] "AphiaID"           "url"               "scientificname"   
#>  [4] "authority"         "status"            "unacceptreason"   
#>  [7] "taxonRankID"       "rank"              "valid_AphiaID"    
#> [10] "valid_name"        "valid_authority"   "parentNameUsageID"
#> [13] "kingdom"           "phylum"            "class"            
#> [16] "order"             "family"            "genus"            
#> [19] "citation"          "lsid"              "isMarine"         
#> [22] "isBrackish"        "isFreshwater"      "isTerrestrial"    
#> [25] "isExtinct"         "match_type"        "modified"
Created on 2022-09-27 with reprex v2.0.2
Session Info

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.2.0 (2022-04-22 ucrt)
#> os Windows 10 x64 (build 19044)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Dutch_Belgium.utf8
#> ctype Dutch_Belgium.utf8
#> tz Europe/Paris
#> date 2022-09-27
#> pandoc 2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> cachem 1.0.6 2021-08-19 [1] CRAN (R 4.2.1)
#> callr 3.7.2 2022-08-22 [1] CRAN (R 4.2.1)
#> cli 3.4.0 2022-09-08 [1] CRAN (R 4.2.1)
#> crayon 1.5.1 2022-03-26 [1] CRAN (R 4.2.1)
#> devtools 2.4.4 2022-07-20 [1] CRAN (R 4.2.1)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 4.2.1)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.1)
#> evaluate 0.16 2022-08-09 [1] CRAN (R 4.2.1)
#> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.2.1)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.1)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.2.1)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.1)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.2.1)
#> htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.2.1)
#> htmlwidgets 1.5.4 2021-09-08 [1] CRAN (R 4.2.1)
#> httpuv 1.6.6 2022-09-08 [1] CRAN (R 4.2.1)
#> knitr 1.40 2022-08-24 [1] CRAN (R 4.2.1)
#> later 1.3.0 2021-08-18 [1] CRAN (R 4.2.1)
#> lifecycle 1.0.2 2022-09-09 [1] CRAN (R 4.2.1)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.1)
#> memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.1)
#> mime 0.12 2021-09-28 [1] CRAN (R 4.2.0)
#> miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.1)
#> pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.1)
#> pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.2.1)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.1)
#> pkgload 1.3.0 2022-06-27 [1] CRAN (R 4.2.1)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.1)
#> processx 3.7.0 2022-07-07 [1] CRAN (R 4.2.1)
#> profvis 0.3.7 2020-11-02 [1] CRAN (R 4.2.1)
#> promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.2.1)
#> ps 1.7.1 2022-06-18 [1] CRAN (R 4.2.1)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.2.1)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.1)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0)
#> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.0)
#> R.utils 2.12.0 2022-06-28 [1] CRAN (R 4.2.1)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.1)
#> Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.2.1)
#> remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.1)
#> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.1)
#> rlang 1.0.5 2022-08-31 [1] CRAN (R 4.2.1)
#> rmarkdown 2.16 2022-08-24 [1] CRAN (R 4.2.1)
#> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.1)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.1)
#> shiny 1.7.2 2022-07-19 [1] CRAN (R 4.2.1)
#> stringi 1.7.8 2022-07-11 [1] CRAN (R 4.2.1)
#> stringr 1.4.1 2022-08-20 [1] CRAN (R 4.2.1)
#> styler 1.7.0 2022-03-13 [1] CRAN (R 4.2.1)
#> tibble 3.1.8 2022-07-22 [1] CRAN (R 4.2.1)
#> urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.1)
#> usethis 2.1.6 2022-05-25 [1] CRAN (R 4.2.1)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.2.1)
#> vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.2.1)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.1)
#> xfun 0.33 2022-09-12 [1] CRAN (R 4.2.1)
#> xtable 1.8-4 2019-04-21 [1] CRAN (R 4.2.1)
#> yaml 2.3.5 2022-02-21 [1] CRAN (R 4.2.0)
#>
#> [1] C:/R/library
#> [2] C:/R/R-4.2.0/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
Created on 2022-09-27 with reprex v2.0.2

WORMS API changes

  • 2019-05-10
    • AphiaRecord object now exposes its taxonRankID
    • Added functions AphiaTaxonRanksByID & AphiaTaxonRanksByName functions to get information about the available ranks in the system
    • Added function AphiaRecordsByTaxonRankID to get all entries of specific rank. Can be limited to a certain AphiaID its descendants (eg: Get all species in a specified family).
    • matchAphiaRecordsByNames (soap) & AphiaRecordsByMatchNames (rest): Now both return the current (final) accepted name (similar as in the update from 2018-10-01)
  • 2018-02-01 Added offset parameter to support fetching more than 50 results getAphiaSynonymsByID
  • 2018-11-27 lowercase the parameter 'aphiaids' for the function AphiaRecordsByAphiaIDs
  • 2018-11-06 added function AphiaRecordsByAphiaIDs to get an AphiaRecord for multiple AphiaIDs in one go

wm_records_taxamatch should not throw an error on empty results

wm_records_taxamatch() throws an error when none of the submitted names have results. If only some names do not have results, the empty results sets are represented by an empty tibble. This inconsistency complicates integration, but moreover, common practice is to only throw errors for unexpected conditions which prevent the function from continuing.

> worrms::wm_records_taxamatch("xxxxxxxx")
Error: (204) No Content - AphiaRecordsByMatchNames
> worrms::wm_records_taxamatch(c("xxxxxxxx", "Abra alba"))
[[1]]
# A tibble: 0 × 0

[[2]]
# A tibble: 1 × 27
  AphiaID url       scien…¹ autho…² status unacc…³ taxon…⁴ rank  valid…⁵ valid…⁶ valid…⁷ paren…⁸ kingdom phylum class order
    <int> <chr>     <chr>   <chr>   <chr>  <lgl>     <int> <chr>   <int> <chr>   <chr>     <int> <chr>   <chr>  <chr> <chr>
1  141433 https://Abra a… (W. WoaccepNA          220 Spec141433 Abra a… (W. Wo138474 AnimalMolluBivaCard# … with 11 more variables: family <chr>, genus <chr>, citation <chr>, lsid <chr>, isMarine <int>, isBrackish <lgl>,
#   isFreshwater <lgl>, isTerrestrial <lgl>, isExtinct <lgl>, match_type <chr>, modified <chr>, and abbreviated variable
#   names ¹​scientificname, ²​authority, ³​unacceptreason, ⁴​taxonRankID, ⁵​valid_AphiaID, ⁶​valid_name, ⁷​valid_authority,
#   ⁸​parentNameUsageID

wm_attr_data_() Error: (204) No content

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

Ungraceful fail condition on 206 error

Hello! Loving this package, as taxize doesn't get synonyms from WORMS that I can tell.

But - I'm running into a funny problem. wm_name2id will often return a 206 error.

library(worrms)

wm_records_name("Asterias rubens")

Error: (206) Partial Content - Asterias rubens

This is odd, as I whipped up a function to do an endrun around the problem, and it works fine

library(dplyr)


get_id <- function(.x){
  
  rec <- try(wm_records_name(.x))
  if(class(rec) == "try-error"){return(NA)}
  
  rec %>%
    filter(status=="accepted") %>%
    pull(AphiaID) 
}

What's going on here? And/or if this is an api, not a package problem, could something like the function I wrote above be a good workaround fail condition?

Here it is without dplyr - and, again, this would only happen if a 206 error was thrown, and I'm guessing a more graceful failure condition (if there are no records) could be added - although if it's a 206, there should be some records.

get_id <- function(.x){
  
  rec <- try(wm_records_name(.x))
  if(class(rec) == "try-error"){return(NA)}
  
  acc <- subset(rec, rec$status=="accepted")
  acc$AphiaID[1]
}

Add retrying?

I just got this error

 Error in curl::curl_fetch_memory(x$url$url, handle = x$url$handle) :
  Error in the HTTP2 framing layer

for a query that has worked previously and worked again after that. Would using RETRY instead of GET help with this?

Maintenance status / help needed?

👋 @bart-v

Do you still intend to become this package's maintainer?

If so do you need any help? For instance an aspect where you'd appreciate some tips, contributions, a PR review? Do you need an invitation to our friendly Slack workspace?

Classification as data frame

Hi @sckott - I've been using this package and found I wanted the output of wm_classification() to run over a list of species and end up as a data frame - the output of this is somewhat different from what you get from wm_record(), in particular the classification function returns 'non-standard' taxonomic groups (superfamily etc.) which I happen to need for this application. Anyway, I've written a couple of functions, which I thought I'd upload here in case you felt there is any more general use for them? The first just turns the output from wm_classification() into a data frame (and attempts to do something sensible with errors), the second runs this over a list of species and then binds all the resulting data frames together into a single tbl_df of classifications for the whole species list:

get_sp_classif <- function(sp){
	
	# try to get WoRMS aphia ID from name
	aphia <- try(wm_name2id(sp), silent = TRUE)
	# check if this worked (catches unrecognised names and instances where AphiaID of -999 is returned)
	if(identical(class(aphia), "try-error") | aphia < 0){
		# try using genus
		aphia <- try(wm_name2id(stringr::word(sp, 1)), silent = TRUE)	
		if(identical(class(aphia), "try-error") | aphia < 0){	
			# return NULL if no aphia ID was found
			classif_df <- data.frame(sciname = sp)
			aphia <- NA
		}
	}
	if(!is.na(aphia)){
		# if aphia ID was found, get full classification
		classif <- wm_classification(aphia)
		# convert into data frame
		classif_df <- read.csv(text = "",
			col.names = c("sciname", "AphiaID", classif$rank),
			colClasses = c("character", "numeric", rep("character", length(classif$rank))), stringsAsFactors = FALSE)
		if("Species" %in% classif$rank){
			classif_df[1,] <- cbind(sp, classif$AphiaID[classif$rank == "Species"], t(classif$scientificname))
		} else {
			classif_df[1,] <- cbind(sp, NA, t(classif$scientificname))
		}
	}

	classif_df
		
	}
sp_list_classif <- function(sp_list){
	
	# run the classification function over the whole list
	classifs <- sapply(sp_list, function(sp_list){get_sp_classif(sp = sp_list)})
	
	# return as dataframe
	classifs <- dplyr::bind_rows(classifs)
	
	dplyr::tbl_df(classifs)		
}

Warning data_frame()` was deprecated

`data_frame()` was deprecated in tibble 1.1.0.
Please use `tibble()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 
Session Info
 version  R version 4.2.0 (2022-04-22 ucrt)
 os       Windows 10 x64 (build 22000)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/Los_Angeles
 date     2022-06-17
 rstudio  2022.02.3+492 Prairie Trillium (desktop)
 pandoc   NAPackages ───────────────────────────────────────────
 package     * version date (UTC) lib source
 brio          1.1.3   2021-11-30 [1] CRAN (R 4.2.0)
 cachem        1.0.6   2021-08-19 [1] CRAN (R 4.2.0)
 callr         3.7.0   2021-04-20 [1] CRAN (R 4.2.0)
 cli           3.3.0   2022-04-25 [1] CRAN (R 4.2.0)
 crayon        1.5.1   2022-03-26 [1] CRAN (R 4.2.0)
 crul          1.2.0   2021-11-22 [1] CRAN (R 4.2.0)
 curl        * 4.3.2   2021-06-23 [1] CRAN (R 4.2.0)
 desc          1.4.1   2022-03-06 [1] CRAN (R 4.2.0)
 devtools      2.4.3   2021-11-30 [1] CRAN (R 4.2.0)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.2.0)
 fansi         1.0.3   2022-03-24 [1] CRAN (R 4.2.0)
 fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.2.0)
 fs            1.5.2   2021-12-08 [1] CRAN (R 4.2.0)
 glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.0)
 httpcode      0.3.0   2020-04-10 [1] CRAN (R 4.2.0)
 jsonlite    * 1.8.0   2022-02-22 [1] CRAN (R 4.2.0)
 lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.2.0)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.0)
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.2.0)
 pillar        1.7.0   2022-02-01 [1] CRAN (R 4.2.0)
 pkgbuild      1.3.1   2021-12-20 [1] CRAN (R 4.2.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.2.0)
 pkgload       1.2.4   2021-11-30 [1] CRAN (R 4.2.0)
 prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.2.0)
 processx      3.5.3   2022-03-25 [1] CRAN (R 4.2.0)
 ps            1.7.0   2022-04-23 [1] CRAN (R 4.2.0)
 purrr         0.3.4   2020-04-17 [1] CRAN (R 4.2.0)
 R6            2.5.1   2021-08-19 [1] CRAN (R 4.2.0)
 Rcpp          1.0.8.3 2022-03-17 [1] CRAN (R 4.2.0)
 remotes       2.4.2   2021-11-30 [1] CRAN (R 4.2.0)
 rlang         1.0.2   2022-03-04 [1] CRAN (R 4.2.0)
 rprojroot     2.0.3   2022-04-02 [1] CRAN (R 4.2.0)
 rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.2.0)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.0)
 testthat      3.1.4   2022-04-26 [1] CRAN (R 4.2.0)
 tibble        3.1.7   2022-05-03 [1] CRAN (R 4.2.0)
 triebeard     0.3.0   2016-08-04 [1] CRAN (R 4.2.0)
 urltools      1.7.3   2019-04-14 [1] CRAN (R 4.2.0)
 usethis       2.1.6   2022-05-25 [1] CRAN (R 4.2.0)
 utf8          1.2.2   2021-07-24 [1] CRAN (R 4.2.0)
 vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.2.0)
 withr         2.5.0   2022-03-03 [1] CRAN (R 4.2.0)
 worrms      * 0.4.3   2022-06-18 [1] local

ERROR 414 Request-URI Too Long - AphiaRecordsByNames issue

Hi all,

I apologize in advance, I'm not sure if my reprex is properly working. I'm trying to run wm_records_names() on n=233 unique taxa, but the error I'm getting is

Error: (414) Request-URI Too Long - AphiaRecordsByNames

If I split it up into two separate character lists, it seems to run fine, but seems to not like 233 unique taxa. Is this a known issue? One of this values in the list is a blank cell (""), but even removing this didn't seem to resolve the issue. There will be species names in there that are misspelled, but that shouldn't result in the error thrown right?

Again, my apologies if the reprex is not proper, if it's required to tackle this issue I'll edit this post. I've added the file that contains the species list here: zoop_species.csv

Thank you in advance!

Session Info
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

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

other attached packages:
 [1] worms_0.2.2      plyr_1.8.7       httr_1.4.3       DiagrammeR_1.0.9 dm_1.0.0         oce_1.7-8       
 [7] gsw_1.0-6        janitor_2.1.0    chron_2.3-57     here_1.0.1       readxl_1.4.0     lubridate_1.8.0 
[13] forcats_0.5.1    stringr_1.4.0    dplyr_1.0.9      purrr_0.3.4      readr_2.1.2      tidyr_1.2.0     
[19] tibble_3.1.7     ggplot2_3.4.0    tidyverse_1.3.2 

loaded via a namespace (and not attached):
 [1] fs_1.5.2            bit64_4.0.5         RColorBrewer_1.1-3  rprojroot_2.0.3     worrms_0.4.2       
 [6] tools_4.2.1         backports_1.4.1     utf8_1.2.2          R6_2.5.1            DBI_1.1.3          
[11] colorspace_2.0-3    withr_2.5.0         tidyselect_1.1.2    leaflet_2.1.1       bit_4.0.4          
[16] curl_4.3.2          compiler_4.2.1      cli_3.3.0           rvest_1.0.2         xml2_1.3.3         
[21] triebeard_0.3.0     scales_1.2.0        digest_0.6.29       rmarkdown_2.14      pkgconfig_2.0.3    
[26] htmltools_0.5.3     dbplyr_2.2.1        fastmap_1.1.0       htmlwidgets_1.5.4   rlang_1.0.6        
[31] rstudioapi_0.13     httpcode_0.3.0      shiny_1.7.2         visNetwork_2.1.0    generics_0.1.3     
[36] jsonlite_1.8.0      vroom_1.5.7         crosstalk_1.2.0     googlesheets4_1.0.0 magrittr_2.0.3     
[41] Rcpp_1.0.9          munsell_0.5.0       fansi_1.0.3         lifecycle_1.0.3     yaml_2.3.5         
[46] stringi_1.7.8       snakecase_0.11.0    grid_4.2.1          parallel_4.2.1      promises_1.2.0.1   
[51] crayon_1.5.1        haven_2.5.0         hms_1.1.1           knitr_1.39          pillar_1.8.0       
[56] igraph_1.3.4        crul_1.2.0          reprex_2.0.1        glue_1.6.2          evaluate_0.15      
[61] modelr_0.1.8        vctrs_0.5.1         tzdb_0.3.0          httpuv_1.6.5        urltools_1.7.3     
[66] cellranger_1.1.0    gtable_0.3.0        assertthat_0.2.1    cachem_1.0.6        xfun_0.31          
[71] mime_0.12           xtable_1.8-4        broom_1.0.0         later_1.3.0         googledrive_2.0.0  
[76] gargle_1.2.0        memoise_2.0.1       writexl_1.4.0       ellipsis_0.3.2     
> 
Reprex
zoop$scientific_name <- trimws(zoop$scientific_name, "r")
sci_names <- unique(zoop$scientific_name)
worms_id <- worrms::wm_records_names(sci_names, marine_only = F) %>% bind_rows()
-- **ERROR: (414) Request-URI Too Long - AphiaRecordsByNames** --

unique(zoop$scientific_name)
  [1] ""                              "Clione limacina"               "Eucalanus bungii"             
  [4] "Eukrohnia hamata"              "Neocalanus cristatus"          "Parasagitta elegans"          
  [7] "Acartia longiremis"            "Calanus"                       "Calocalanus styliremis"       
 [10] "Candacia"                      "Clausocalanus parapergens"     "Clausocalanus"                
 [13] "Disconchoecia elegans"         "Heterostylites"                "Limacina helicina"            
 [16] "Metridia pacifica"             "Metridia"                      "Neocalanus"                   
 [19] "Oithona atlantica"             "Oithona similis"               "Oithona"                      
 [22] "Paracalanus indicus"           "Paracalanus parvus"            "Paracalanus"                  
 [25] "Paraeuchaeta"                  "Pseudocalanus moultoni"        "Pseudocalanus newmani"        
 [28] "Pseudocalanus"                 "Racovitzanus antarcticus"      "Racovitzanus"                 
 [31] "Scolecithricella minor"        "Pseudosagitta scrippsae"       "Aglantha digitale"            
 [34] "Euaugaptilus nodifrons"        "Euphausia pacifica"            "Oikopleura labradoriensis"    
 [37] "Paraeuchaeta elongata"         "Streetsia challengeri"         "Thysanoessa longipes"         
 [40] "Tomopteris septentrionalis"    "Alacia minor"                  "Atlanta"                      
 [43] "Conchoecia spinirostris"       "Corycaeus anglicus"            "Ctenocalanus vanus"           
 [46] "Eucalanus"                     "Euchirella"                    "Fritillaria borealis"         
 [49] "Gaetanus intermedius"          "Gaetanus"                      "Heterostylites longicornis"   
 [52] "Lucicutia flavicornis"         "Mesocalanus"                   "Mesocalanus tenucornis"       
 [55] "Microcalanus pygmaeus"         "Oikopleura dioica"             "Pleuromamma"                  
 [58] "Scaphocalanus brevicaudatus"   "Tomopteris"                    "Triconia conifera"            
 [61] "Eusergestes similis"           "Cyphocaris challengeri"        "Thysanoessa inspinata"        
 [64] "Aetideus divergens"            "Eusergestes"                   "Heterostylites major"         
 [67] "Pleuromamma scutullata"        "Aequorea victoria"             "Chelophyes appendiculata"     
 [70] "Corolla spectabilis"           "Themisto pacifica"             "Ctenocalanus"                 
 [73] "Neocalanus plumchrus"          "Pseudocalanus mimus"           "Scocithricella minor"         
 [76] "Phronima"                      "Protomyctophum thompsoni"      "Stenobrachius leucopsarus"    
 [79] "Aetideus"                      "Calanus marshallae"            "Muggiae atlantica"            
 [82] "Lucutia flavicornis"           "Microcalanus"                  "Scocithricella"               
 [85] "Spinocalanus brevicaudatus"    "Lensia baryi"                  "Dimophyes arctica"            
 [88] "Microcalanus pusillus"         "Clio pyramidata"               "Vibilia"                      
 [91] "Clio"                          "Triconia ivlevi"               "Thysanoessa spinifera"        
 [94] "Tarletonbeania crenularis"     "Primno abyssalis"              "Salpa aspera"                 
 [97] "Bradyidius similis"            "Clausocalanus arcuicornis"     "Lophothrix frontalis"         
[100] "Tessarabrachion occulatum"     "Scaphocalanus echinatus"       "Oikopleura"                   
[103] "Pleuromamma quadrungulata"     "Clione"                        "Aetideus pacificus"           
[106] "Nematocelis difficilis"        "Aegina citrea"                 "Scaphocalanus magnus"         
[109] "Tuscaretta globulosa"          "Euchirella rostrata"           "Candacia columbiae"           
[112] "Heterorhabdus tanneri"         "Scina"                         "Aglantha"                     
[115] "Munida quadrispina"            "Arietellus plumifer"           "Nanomia bijuga"               
[118] "Periphylla periphylla"         "Heterorhabdus papilliger"      "Hyperia medusarum"            
[121] "Thysanoessa inermis"           "Chiridius gracilis"            "Heterorhabdus"                
[124] "Triconia"                      "Microsetella rosea"            "Symbolophorous californiensis"
[127] "Stylocheiron maximum"          "Pseudolubbockia dilatata"      "Triconia borealis"            
[130] "Euphausia pacficia"            "Thysanoessa lonipes"           "Coelodendrum"                 
[133] "Bathylagus pacificus"          "Scolecithricella"              "Paraphronima crassipes"       
[136] "Bathylagus milleri"            "Primno pacifica"               "Pseudocalanus minutus"        
[139] "Lensia conoidea"               "Tessarabrachion oculatum"      "Aglama elegans"               
[142] "Hormiphora"                    "Paraphronima gracilis"         "Rhynchonereella angellini"    
[145] "Calanus pacificus"             "Euchirella curticaudata"       "Sardinops sagax"              
[148] "Sebastes"                      "Atlanta inflata"               "Carinaria japonica"           
[151] "Cliopsis krohnii"              "Psuedosagitta scrippsae"       "Calocalanus"                  
[154] "Candacia bipinnata"            "Chiridius"                     "Bathylagus ochotensis"        
[157] "Spinocalanus longicornis"      "Pleuromamma scutulata"         "Cancer"                       
[160] "Chauliodus macouni"            "Cystisoma"                     "Gaetanus minutus"             
[163] "Metridia curticaudata"         "Spinocalanus"                  "Metridia curicaudata"         
[166] "Symbolophorus californiensis"  "Clio recurva"                  "Calanoid A"                   
[169] "Clytemnestra"                  "Caesaromysis hispida"          "Lucicutia"                    
[172] "Pseudocalanus styliremis"      "Pseudocalanus flavicornis"     "Pseudocalanus dioica"         
[175] "Pseudocalanus atlantica"       "Clupea pallasi"                "Oithona spinirostris"         
[178] "Euchaeta elongata"             "Ostracoda"                     "Parathemisto pacifica"        
[181] "Euphausiidae"                  "Polychaeta"                    "Gastropoda"                   
[184] "Sagitta elegans"               "Siphonophorae"                 "Cnidaria"                     
[187] "Pisces"                        "Aetideidae"                    "Primno macropa"               
[190] "Zoanthidea"                    "Sergestes"                     "Gaetanus simplex"             
[193] "Mesocalanus tenuicornis"       "Isopoda"                       "Phronima sedentaria"          
[196] "Hyperia"                       "Gaidius"                       "Sagitta scrippsae"            
[199] "Aegina"                        "Chionoecetes"                  "Bryozoa"                      
[202] "Teuthida"                      "Narcomedusae"                  "Echinospira"                  
[205] "Fritillaria"                   "Nemertina"                     "Scolecithricella ovata"       
[208] "Pasiphaea pacifica"            "Octopus"                       "Scinidae"                     
[211] "Conchoecia"                    "Euphausiacea"                  "Metridia okhotensis"          
[214] "Neocalanus flemingeri"         "Alciopidae"                    "Harpacticoida"                
[217] "Acartia"                       "Euchaeta media"                "Oncaea"                       
[220] "Sergestidae"                   "Caridea"                       "Myctophidae"                  
[223] "Acartia danae"                 "Doliolidae"                    "Lubbockia wilsonae"           
[226] "Scaphocalanus"                 "Aegina rosea"                  "Pleuromamma abdominalis"      
[229] "Pandalidae"                    "Sergestes similis"             "Mecynocera clausi"            
[232] "Nematoscelis"                  "Pareucalanus parki"  

Add new maintainer to DESCRIPTION

@bart-v thanks for your answer! Could you please add yourself to the DESCRIPTION file with the "aut" and "cre" roles so that the maintainer change is registered? Thank you!!

access to "host/prey" and "host/prey of" data

Hi,
I may be missing something but when retrieving attribute data, eg.

attr=wm_attr_data(id = 107381, include_inherited = TRUE)

I get all the info I see here except for the "host/prey of" info. Is there a way to access those?

Thanks!
Angelos

Session Info
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

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

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

other attached packages:
[1] readxl_1.3.1 worrms_0.4.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5       rstudioapi_0.11  magrittr_1.5     R6_2.4.1         rlang_0.4.5      fansi_0.4.1      tools_3.6.3      utf8_1.1.4      
 [9] cli_2.0.2        ellipsis_0.3.0   assertthat_0.2.1 tibble_3.0.1     httpcode_0.2.0   lifecycle_0.2.0  crayon_1.3.4     vctrs_0.2.4     
[17] rsconnect_0.8.16 triebeard_0.3.0  curl_4.3         crul_0.9.0       glue_1.3.2       compiler_3.6.3   pillar_1.4.3     cellranger_1.1.0
[25] urltools_1.7.3   jsonlite_1.6.1   pkgconfig_2.0.3 

Error: lexical error: invalid char in json text

Hi everyone,
trying to run any of the code present in the readme or this link I've error in

Error: lexical error: invalid char in json text.
<meta http-equiv='C
(right here) ------^

I've thinking this error is with json version but not sure I do not how to fix it to connect to worms API. Any suggestion ?

sessionInfo()
R version 3.4.2 (2017-09-28)Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 17.10
Matrix products: defaultBLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=es_MX.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=es_MX.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=es_MX.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_MX.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] jsonlite_1.5 worrms_0.2.6.9100 bindrcpp_0.2 dplyr_0.7.4
[5] DT_0.4 shiny_1.0.5 ggplot2_2.2.1.9000 phyloseq_1.22.3

Document limit in wm_record

The wm_record function doesn't document the limit of 50 identifiers, and I think it would be useful to include this in the help documentation.

Error: lexical error: invalid char in json text. when using wm_name2id_()

Hi there!

I am trying to use wm_name2id_() and getting a very strange error. Can you help me understand why? This error did not occur with another set of names, only this set triggered the error. See file in link (referred to as 'all_children$child' in the code segment below) for the names I am passing to wm_name2id_() that results in this error. Thanks for the help!

child_AID <- wm_name2id_(all_children$child)
Error: lexical error: invalid char in json text.

400 Bad request
(right here) ------^

https://drive.google.com/file/d/1KBx-pG_h-fK5Rw1RY4feHhbwteEdlkMs/view?usp=sharing

P.S. I already tried encoding the names as "UTF-8", but that didn't seem to help.

wm_records_name() & wm_name2id_() produces "Error: (400) Bad Request" on some systems when there are spaces in query

While debugging an issue with taxize, I found that wm_records_name fails on some systems (a clean Windows install in this case). It might have something to do with how spaces in the URL call to the Worrms API are formatted, although I am not sure. Here is a reprex I was using to debug the error:

library(worrms)
wm_records_name("Gadus morhua")
#> Error: (400) Bad Request - Gadus morhua

Created on 2022-03-29 by the reprex package (v2.0.1)

The error happens in the internal function wm_GET. It produces this URL:

https://www.marinespecies.org/rest/AphiaRecordsByName/Gadus morhua?like=true&marine_only=true&offset=1

Which results in a "(400) Bad Request" error when called with crul::HttpClient, but works when pasting into an internet browser (Firefox in my case). The browser replaces the space in "Gadus morhua" with "%20" automatically, making the URL:

https://www.marinespecies.org/rest/AphiaRecordsByName/Gadus%20morhua?like=true&marine_only=true&offset=1

This error did not occur on my Linux system (PopOS).

Session Info
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

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

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

other attached packages:
[1] worrms_0.4.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3      fansi_1.0.2       utf8_1.2.2        crayon_1.5.0      crul_1.2.0        R6_2.5.1          jsonlite_1.8.0    lifecycle_1.0.1  
 [9] magrittr_2.0.2    pillar_1.7.0      rlang_1.0.2       cli_3.2.0         curl_4.3.2        data.table_1.14.2 vctrs_0.3.8       ellipsis_0.3.2   
[17] urltools_1.7.3    tools_4.1.3       glue_1.6.2        triebeard_0.3.0   compiler_4.1.3    pkgconfig_2.0.3   tibble_3.1.6      httpcode_0.3.0  

wm_name2id_() produces error for some names

worrms::wm_name2id_(c("Potamilla (Pseudopotamilla) reniformis"))
#> Warning: (400) Bad Request - Potamilla (Pseudopotamilla) reniformis
#> Error: lexical error: invalid char in json text.
#>                                        <html><body><h1>400 Bad request
#>                      (right here) ------^

Created on 2022-06-17 by the reprex package (v2.0.1)

Session Info
 version  R version 4.2.0 (2022-04-22 ucrt)
 os       Windows 10 x64 (build 22000)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/Los_Angeles
 date     2022-06-17
 rstudio  2022.02.3+492 Prairie Trillium (desktop)
 pandoc   2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)

─ Packages ───────────────────────────────────────────────
 package     * version date (UTC) lib source
 brio          1.1.3   2021-11-30 [1] CRAN (R 4.2.0)
 cachem        1.0.6   2021-08-19 [1] CRAN (R 4.2.0)
 callr         3.7.0   2021-04-20 [1] CRAN (R 4.2.0)
 cli           3.3.0   2022-04-25 [1] CRAN (R 4.2.0)
 clipr         0.8.0   2022-02-22 [1] CRAN (R 4.2.0)
 crayon        1.5.1   2022-03-26 [1] CRAN (R 4.2.0)
 desc          1.4.1   2022-03-06 [1] CRAN (R 4.2.0)
 devtools      2.4.3   2021-11-30 [1] CRAN (R 4.2.0)
 digest        0.6.29  2021-12-01 [1] CRAN (R 4.2.0)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.2.0)
 evaluate      0.15    2022-02-18 [1] CRAN (R 4.2.0)
 fansi         1.0.3   2022-03-24 [1] CRAN (R 4.2.0)
 fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.2.0)
 fs            1.5.2   2021-12-08 [1] CRAN (R 4.2.0)
 glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.0)
 highr         0.9     2021-04-16 [1] CRAN (R 4.2.0)
 htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.2.0)
 knitr         1.39    2022-04-26 [1] CRAN (R 4.2.0)
 lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.2.0)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.0)
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.2.0)
 pillar        1.7.0   2022-02-01 [1] CRAN (R 4.2.0)
 pkgbuild      1.3.1   2021-12-20 [1] CRAN (R 4.2.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.2.0)
 pkgload       1.2.4   2021-11-30 [1] CRAN (R 4.2.0)
 prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.2.0)
 processx      3.5.3   2022-03-25 [1] CRAN (R 4.2.0)
 ps            1.7.0   2022-04-23 [1] CRAN (R 4.2.0)
 purrr         0.3.4   2020-04-17 [1] CRAN (R 4.2.0)
 R6            2.5.1   2021-08-19 [1] CRAN (R 4.2.0)
 remotes       2.4.2   2021-11-30 [1] CRAN (R 4.2.0)
 reprex        2.0.1   2021-08-05 [1] CRAN (R 4.2.0)
 rlang         1.0.2   2022-03-04 [1] CRAN (R 4.2.0)
 rmarkdown     2.14    2022-04-25 [1] CRAN (R 4.2.0)
 rprojroot     2.0.3   2022-04-02 [1] CRAN (R 4.2.0)
 rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.2.0)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.0)
 testthat      3.1.4   2022-04-26 [1] CRAN (R 4.2.0)
 tibble        3.1.7   2022-05-03 [1] CRAN (R 4.2.0)
 usethis       2.1.6   2022-05-25 [1] CRAN (R 4.2.0)
 utf8          1.2.2   2021-07-24 [1] CRAN (R 4.2.0)
 vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.2.0)
 withr         2.5.0   2022-03-03 [1] CRAN (R 4.2.0)
 xfun          0.31    2022-05-10 [1] CRAN (R 4.2.0)
 yaml          2.3.5   2022-02-21 [1] CRAN (R 4.2.0)

Accessing Life stage info for Attributes data

Session Info
Session info -----------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, darwin15.6.0        
 ui       AQUA                        
 language (EN)                        
 collate  en_GB.UTF-8                 
 tz       Europe/London               
 date     2018-08-21                  

Packages ---------------------------------------------------------------------------------------------------
 package       * version date       source        
 assertthat      0.2.0   2017-04-11 CRAN (R 3.5.0)
 backports       1.1.2   2017-12-13 CRAN (R 3.5.0)
 base          * 3.5.1   2018-07-05 local         
 bindr           0.1.1   2018-03-13 CRAN (R 3.5.0)
 bindrcpp      * 0.2.2   2018-03-29 CRAN (R 3.5.0)
 boot          * 1.3-20  2017-08-06 CRAN (R 3.5.1)
 broom           0.5.0   2018-07-17 CRAN (R 3.5.1)
 cellranger      1.1.0   2016-07-27 CRAN (R 3.5.0)
 cli             1.0.0   2017-11-05 CRAN (R 3.5.0)
 colorspace      1.3-2   2016-12-14 CRAN (R 3.5.0)
 compiler        3.5.1   2018-07-05 local         
 cowplot       * 0.9.3   2018-07-15 CRAN (R 3.5.0)
 crayon          1.3.4   2017-09-16 CRAN (R 3.5.0)
 crosstalk       1.0.0   2016-12-21 CRAN (R 3.5.0)
 crul            0.6.0   2018-07-10 CRAN (R 3.5.0)
 curl            3.2     2018-03-28 CRAN (R 3.5.0)
 datasets      * 3.5.1   2018-07-05 local         
 devtools        1.13.6  2018-06-27 CRAN (R 3.5.0)
 digest          0.6.15  2018-01-28 CRAN (R 3.5.0)
 dplyr         * 0.7.6   2018-06-29 CRAN (R 3.5.1)
 fansi           0.2.3   2018-05-06 CRAN (R 3.5.0)
 forcats       * 0.3.0   2018-02-19 CRAN (R 3.5.0)
 ggcorrplot    * 0.1.1   2016-01-12 CRAN (R 3.5.0)
 ggplot2       * 3.0.0   2018-07-03 CRAN (R 3.5.0)
 glue            1.2.0   2017-10-29 CRAN (R 3.5.0)
 graphics      * 3.5.1   2018-07-05 local         
 grDevices     * 3.5.1   2018-07-05 local         
 grid            3.5.1   2018-07-05 local         
 gridExtra       2.3     2017-09-09 CRAN (R 3.5.0)
 gtable          0.2.0   2016-02-26 CRAN (R 3.5.0)
 haven           1.1.2   2018-06-27 CRAN (R 3.5.0)
 hms             0.4.2   2018-03-10 CRAN (R 3.5.0)
 htmltools       0.3.6   2017-04-28 CRAN (R 3.5.0)
 htmlwidgets     1.2     2018-04-19 CRAN (R 3.5.0)
 httpcode        0.2.0   2016-11-14 CRAN (R 3.5.0)
 httpuv          1.4.4.2 2018-07-02 CRAN (R 3.5.0)
 httr            1.3.1   2017-08-20 CRAN (R 3.5.0)
 jsonlite        1.5     2017-06-01 CRAN (R 3.5.0)
 later           0.7.3   2018-06-08 CRAN (R 3.5.0)
 lattice         0.20-35 2017-03-25 CRAN (R 3.5.1)
 lazyeval        0.2.1   2017-10-29 CRAN (R 3.5.0)
 leaflet         2.0.1   2018-06-04 CRAN (R 3.5.0)
 lubridate     * 1.7.4   2018-04-11 CRAN (R 3.5.0)
 magrittr        1.5     2014-11-22 CRAN (R 3.5.0)
 Matrix          1.2-14  2018-04-13 CRAN (R 3.5.1)
 memoise         1.1.0   2017-04-21 CRAN (R 3.5.0)
 methods       * 3.5.1   2018-07-05 local         
 mime            0.5     2016-07-07 CRAN (R 3.5.0)
 modelr          0.1.2   2018-05-11 CRAN (R 3.5.0)
 MuMIn         * 1.42.1  2018-07-23 CRAN (R 3.5.0)
 munsell         0.5.0   2018-06-12 CRAN (R 3.5.0)
 naniar        * 0.3.1   2018-06-08 CRAN (R 3.5.0)
 ncdf4         * 1.16    2017-04-01 CRAN (R 3.5.0)
 nlme            3.1-137 2018-04-07 CRAN (R 3.5.1)
 pillar          1.3.0   2018-07-14 CRAN (R 3.5.0)
 pkgconfig       2.0.1   2017-03-21 CRAN (R 3.5.0)
 plyr            1.8.4   2016-06-08 CRAN (R 3.5.0)
 promises        1.0.1   2018-04-13 CRAN (R 3.5.0)
 purrr         * 0.2.5   2018-05-29 CRAN (R 3.5.0)
 R6              2.2.2   2017-06-17 CRAN (R 3.5.0)
 raster        * 2.6-7   2017-11-13 CRAN (R 3.5.0)
 Rcpp            0.12.17 2018-05-18 CRAN (R 3.5.0)
 readr         * 1.1.1   2017-05-16 CRAN (R 3.5.0)
 readxl          1.1.0   2018-04-20 CRAN (R 3.5.0)
 rfishbase     * 2.1.2   2017-04-19 CRAN (R 3.5.0)
 rgdal         * 1.3-4   2018-08-03 CRAN (R 3.5.0)
 rlang           0.2.1   2018-05-30 CRAN (R 3.5.0)
 robis         * 1.0.1   2018-07-02 CRAN (R 3.5.0)
 rstudioapi      0.7     2017-09-07 CRAN (R 3.5.0)
 rvest           0.3.2   2016-06-17 CRAN (R 3.5.0)
 scales          0.5.0   2017-08-24 CRAN (R 3.5.0)
 sdmpredictors * 0.2.8   2018-07-19 CRAN (R 3.5.0)
 shiny           1.1.0   2018-05-17 CRAN (R 3.5.0)
 sp            * 1.3-1   2018-06-05 CRAN (R 3.5.0)
 stats         * 3.5.1   2018-07-05 local         
 stats4          3.5.1   2018-07-05 local         
 stringi         1.2.3   2018-06-12 CRAN (R 3.5.0)
 stringr       * 1.3.1   2018-05-10 CRAN (R 3.5.0)
 tibble        * 1.4.2   2018-01-22 CRAN (R 3.5.0)
 tidyr         * 0.8.1   2018-05-18 CRAN (R 3.5.0)
 tidyselect      0.2.4   2018-02-26 CRAN (R 3.5.0)
 tidyverse     * 1.2.1   2017-11-14 CRAN (R 3.5.0)
 tools           3.5.1   2018-07-05 local         
 triebeard       0.3.0   2016-08-04 CRAN (R 3.5.0)
 urltools        1.7.1   2018-08-03 CRAN (R 3.5.0)
 utf8            1.1.4   2018-05-24 CRAN (R 3.5.0)
 utils         * 3.5.1   2018-07-05 local         
 viridis       * 0.5.1   2018-03-29 CRAN (R 3.5.0)
 viridisLite   * 0.3.0   2018-02-01 CRAN (R 3.5.0)
 visdat          0.5.1   2018-07-04 CRAN (R 3.5.0)
 withr           2.1.2   2018-03-15 CRAN (R 3.5.0)
 worrms        * 0.2.8   2018-05-21 CRAN (R 3.5.0)
 xml2            1.2.0   2018-01-24 CRAN (R 3.5.0)
 xtable          1.8-2   2016-02-05 CRAN (R 3.5.0)
Hi @sckott - got a question about the new attributes functions for accessing WoRMS attributes (i.e. traits). We're interested in Functional Group, but would like this to be further referenced by life stage. For instance, try:
library(worrms)
library(dplyr)
wm_attr_data(id = 107381, include_inherited = TRUE) %>%
  filter(measurementType == "Functional group")

which gives both benthos and plantkon > zooplankton as values for Functional group. But check on WoRMS http://www.marinespecies.org/aphia.php?p=taxdetails&id=107381#attributes and it's clear that benthos is when Stage = adult, zooplankton when Stage = larva. (This is very common for marine species.) My question is whether this stage info is currently available via the web services? If not I can chase up directly with the WoRMS team. Thanks!

Error HTTP 206 when trying AphiaID from taxonomic name

When trying to retrieve an AphiaID from a taxonomic name I get an Error (206) Partial Content. So if I go into WoRMS and manually retrieve the AphiaID and try the opposite (to retrieve the taxonomic name), it works and the name that appears is exactly the same as I typed, so not sure what is the issue. See example in "Session Info" below. I'd appreciate any help/feedback.

Thanks,
Jon

Session Info
> id<-wm_name2id(name ="Haliclystus auricula")
Error: (206) Partial Content - Haliclystus auricula
> dist<-wm_distribution(id = 135322)
> dist
# A tibble: 9 × 10
  locality      locationID higherGeography higherGeographyID recordStatus typeStatus establishmentMeans
  <chr>         <chr>      <chr>           <chr>             <chr>        <lgl>      <lgl>             
1 European wathttp://maNorth Atlantichttp://marineregvalid        NA         NA                
2 Arctic Ocean  http://maArctic Ocean    http://marineregvalid        NA         NA                
3 North West Ahttp://maNorth Atlantichttp://marineregvalid        NA         NA                
4 Wimereux      http://maFrance          http://marineregvalid        NA         NA                
5 Northern Norhttp://maNorth Atlantichttp://marineregvalid        NA         NA                
6 Arctic Ocean  http://maArctic Ocean    http://marineregvalid        NA         NA                
7 Cobscook Bay  http://maBay of Fundy    http://marineregvalid        NA         NA                
8 Gulf of Maine http://maNorth Atlantichttp://marineregvalid        NA         NA                
9 Irish Exclushttp://maIreland         http://marineregvalid        NA         NA                
# ℹ 3 more variables: decimalLatitude <lgl>, decimalLongitude <lgl>, qualityStatus <chr>
> name<-wm_id2name(id = 135322)
> name
[1] "Haliclystus auricula"
> id<-wm_name2id(name="Haliclystus auricula")
Error: (206) Partial Content - Haliclystus auricula

Error when using wm_records_taxamatch( )

When using the wm_records_taxamatch ( ) command to match species, if the species is a variety it returns an error.
For instance:
Using wm_records_taxamatch ("Cystoseira humilis myriophylloides") generates an error: Error: (204) No Content - AphiaRecordsByMatchNames
However, if used by entering wm_records_taxamatch ("Cystoseira humilis var. Myriophylloides") it finds a match.
Isn't there any way that it doesn't take into account the variety of the species?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.