EnquistLab / RTNRS

R package for the (plant) Taxonomic Name Resolution Service
https://bien.nceas.ucsb.edu/bien/tools/tnrs/
Other
8 stars 0 forks source link

Matching scores are not numeric #5

Closed Rekyt closed 1 year ago

Rekyt commented 2 years ago

Hey @bmaitner 👋

I've noticed that all the columns returned by TNRS::TNRS() are character. Which makes it strange when you want to look for matching scores:

# Example query
ex = TNRS::TNRS("Plantago lanceolata")

# Columns containing 'scores' which should be numeric
str(ex[, grepl("score", colnames(ex))])
#> 'data.frame':    1 obs. of  10 variables:
#>  $ Overall_score                : chr "1"
#>  $ Name_score                   : chr "1"
#>  $ Author_score                 : chr ""
#>  $ Genus_score                  : chr "1"
#>  $ Specific_epithet_score       : chr "1"
#>  $ Family_score                 : chr ""
#>  $ Infraspecific_epithet_score  : chr ""
#>  $ Infraspecific_epithet_2_score: chr ""
#>  $ Overall_score_order          : chr "1"
#>  $ Highertaxa_score_order       : chr "1"

Created on 2021-10-19 by the reprex package (v2.0.1)

Session info ``` r sessioninfo::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 4.1.0 (2021-05-18) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate French_France.1252 #> ctype French_France.1252 #> tz Europe/Berlin #> date 2021-10-19 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> backports 1.2.1 2020-12-09 [1] CRAN (R 4.0.3) #> cli 3.0.1 2021-07-17 [1] CRAN (R 4.0.5) #> crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.3) #> curl 4.3.2 2021-06-23 [1] CRAN (R 4.0.5) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.2) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3) #> fansi 0.5.0 2021-05-25 [1] CRAN (R 4.0.5) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.3) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.3) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3) #> highr 0.9 2021-04-16 [1] CRAN (R 4.0.5) #> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.1) #> httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.3) #> jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.3) #> knitr 1.36 2021-09-29 [1] CRAN (R 4.1.1) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.0) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.3) #> pillar 1.6.4 2021-10-18 [1] CRAN (R 4.1.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.3) #> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.0) #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.0.3) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.0.3) #> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.1) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.1) #> rlang 0.4.11 2021-04-30 [1] CRAN (R 4.0.5) #> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.0) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.0.2) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.3) #> stringi 1.7.4 2021-08-25 [1] CRAN (R 4.1.1) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.3) #> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.1) #> tibble 3.1.4 2021-08-25 [1] CRAN (R 4.1.1) #> TNRS 0.2.0 2021-10-19 [1] Github (EnquistLab/RTNRS@d2f1ac4) #> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.0) #> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.5) #> withr 2.4.2 2021-04-18 [1] CRAN (R 4.0.5) #> xfun 0.26 2021-09-14 [1] CRAN (R 4.1.1) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.3) #> #> [1] C:/Users/ke76dimu/Documents/R/R-4.1.0/library ```

I wonder if it is due to the JSON data sent back by the TNRS API or when converting the JSON object within R?

bmaitner commented 2 years ago

Hey @Rekyt thanks for catching that. That doesn't make much sense. @ojalaquellueva and I have some updates to the TNRS to make shortly, including some needed for CRAN compliance and to make maintaining it easier. I'll try to remember to fix this at the same time. @ojalaquellueva is the score sent as a character on your end? Easy enough to change on my end with an as.numeric(), but may be useful to check on your end as well.

bmaitner commented 1 year ago

I've updated the code so that any of the fields ending in "..._score" are now returned as numeric.