Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upProblem with validate_names() #121
Comments
|
@sckott can you take a look at this when you get a chance? |
|
@PMassicotte can you share your |
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(rfishbase) This worksdf <- data_frame(
myname = c("Oreochromis niloticus", "Salmo trutta")
)
df %>%
mutate(valide_name = validate_names(myname))
#> Warning: FishBase says that 'Salmo trutta' can also be misapplied to other species
#> but is returning only the best match.
#> See synonyms('Salmo trutta') for details
#> # A tibble: 2 × 2
#> myname valide_name
#> <chr> <chr>
#> 1 Oreochromis niloticus Oreochromis niloticus
#> 2 Salmo trutta Salmo truttaThis crashesdf <- data_frame(
myname = c("Oreochromis niloticus", "Salmo truttaxxxx")
)
df %>%
mutate(valide_name = validate_names(myname))
#> Warning in check_and_parse(resp): Bad Request (HTTP 400).
#> Warning: no results found for query https://fishbase.ropensci.org/synonyms?
#> SynSpecies=truttaxxxx&SynGenus=Salmo&limit=50&fields=SynGenus%2CSynSpecies
#> %2CValid%2CMisspelling%2CStatus%2CSynonymy%2CCombination%2CSpecCode
#> %2CSynCode%2CCoL_ID%2CTSN%2CWoRMS_ID
#> Warning: Unknown or uninitialised column: 'SpecCode'.
#> Warning: Unknown or uninitialised column: 'SpecCode'.
#> Warning: No match found for species 'Salmo truttaxxxx'
#> # A tibble: 2 × 2
#> myname valide_name
#> <chr> <chr>
#> 1 Oreochromis niloticus Oreochromis niloticus
#> 2 Salmo truttaxxxx Oreochromis niloticus
sessionInfo()
#> R version 3.4.0 (2017-04-21)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Linux Mint 18.1
#>
#> Matrix products: default
#> BLAS: /usr/lib/openblas-base/libblas.so.3
#> LAPACK: /usr/lib/libopenblasp-r0.2.18.so
#>
#> locale:
#> [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
#> [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
#> [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] rfishbase_2.1.2 dplyr_0.5.0
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_0.12.10 tidyr_0.6.2 digest_0.6.12
#> [4] rprojroot_1.2 assertthat_0.2.0 R6_2.2.1
#> [7] jsonlite_1.4 DBI_0.6-1 backports_1.0.5
#> [10] magrittr_1.5 evaluate_0.10 httr_1.2.1
#> [13] stringi_1.1.5 curl_2.6 lazyeval_0.2.0
#> [16] rmarkdown_1.5.9000 tools_3.4.0 stringr_1.2.0
#> [19] yaml_2.1.14 compiler_3.4.0 htmltools_0.3.6
#> [22] knitr_1.15.1 tibble_1.3.0 |
give back NA when no result found in query added utility fxn for defauling to NA when result is NULL or of length 0 bump dev version
|
@PMassicotte can you reinstall and try again. let me know if it works for you now. |
|
Looks like the problem is fixed.
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(rfishbase) This worksdf <- data_frame(
myname = c("Oreochromis niloticus", "Salmo trutta")
)
df %>%
mutate(valide_name = validate_names(myname))
#> Warning: FishBase says that 'Salmo trutta' can also be misapplied to other species
#> but is returning only the best match.
#> See synonyms('Salmo trutta') for details
#> # A tibble: 2 x 2
#> myname valide_name
#> <chr> <chr>
#> 1 Oreochromis niloticus Oreochromis niloticus
#> 2 Salmo trutta Salmo truttaThis works nowdf <- data_frame(
myname = c("Oreochromis niloticus", "Salmo truttaxxxx")
)
df %>%
mutate(valide_name = validate_names(myname))
#> Warning in check_and_parse(resp): Bad Request (HTTP 400).
#> Warning: no results found for query https://fishbase.ropensci.org/synonyms?
#> SynSpecies=truttaxxxx&SynGenus=Salmo&limit=50&fields=SynGenus%2CSynSpecies
#> %2CValid%2CMisspelling%2CStatus%2CSynonymy%2CCombination%2CSpecCode
#> %2CSynCode%2CCoL_ID%2CTSN%2CWoRMS_ID
#> Warning: No match found for species 'Salmo truttaxxxx'
#> # A tibble: 2 x 2
#> myname valide_name
#> <chr> <chr>
#> 1 Oreochromis niloticus Oreochromis niloticus
#> 2 Salmo truttaxxxx <NA>
sessionInfo()
#> R version 3.4.0 (2017-04-21)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Linux Mint 18.1
#>
#> Matrix products: default
#> BLAS: /usr/lib/openblas-base/libblas.so.3
#> LAPACK: /usr/lib/libopenblasp-r0.2.18.so
#>
#> locale:
#> [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
#> [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
#> [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] rfishbase_2.1.2.1 dplyr_0.5.0
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_0.12.10 tidyr_0.6.3 digest_0.6.12
#> [4] rprojroot_1.2 assertthat_0.2.0 R6_2.2.1
#> [7] jsonlite_1.4 DBI_0.6-1 backports_1.0.5
#> [10] magrittr_1.5 evaluate_0.10 httr_1.2.1
#> [13] rlang_0.1.1 stringi_1.1.5 curl_2.6
#> [16] lazyeval_0.2.0 rmarkdown_1.5.9000 tools_3.4.0
#> [19] stringr_1.2.0 yaml_2.1.14 compiler_3.4.0
#> [22] htmltools_0.3.6 knitr_1.16 tibble_1.3.1Thank you! |
|
great, glad it works |
Hi there.
I am trying to use this library to extract information from my collected species. I think I found a bug when
validate_names()is not finding the requested species. As you can see in the second example, the valid name is not found, hence it is repeating the last valid name. One solution would be to always return a vector of the same size as the requested list. If the species is not found, simply returnNA.This works
This crashes