worrms/0000755000176200001440000000000013147645027011614 5ustar liggesusersworrms/inst/0000755000176200001440000000000013147642434012570 5ustar liggesusersworrms/inst/doc/0000755000176200001440000000000013147642433013334 5ustar liggesusersworrms/inst/doc/worrms_vignette.html0000644000176200001440000005745713147642433017502 0ustar liggesusers Introduction to the worrms package

Introduction to the worrms package

worrms is an R client for the World Register of Marine Species.

Install

Stable version from CRAN

install.packages("worrms")

Development version from GitHub

install.packages("devtools")
devtools::install_github("ropensci/worrms")
library("worrms")

Get records

WoRMS 'records' are taxa, not specimen occurrences or something else.

by date

wm_records_date('2016-12-23T05:59:45+00:00')
#> # A tibble: 50 x 25
#>    AphiaID                                                           url
#>  *   <int>                                                         <chr>
#>  1  894298 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894298
#>  2  894301 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894301
#>  3  894297 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894297
#>  4  894302 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894302
#>  5  894296 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894296
#>  6  894299 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894299
#>  7  894303 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894303
#>  8  915236 http://www.marinespecies.org/aphia.php?p=taxdetails&id=915236
#>  9  906769 http://www.marinespecies.org/aphia.php?p=taxdetails&id=906769
#> 10  909454 http://www.marinespecies.org/aphia.php?p=taxdetails&id=909454
#> # ... with 40 more rows, and 23 more variables: scientificname <chr>,
#> #   authority <chr>, status <chr>, unacceptreason <lgl>, rank <chr>,
#> #   valid_AphiaID <int>, valid_name <chr>, valid_authority <chr>,
#> #   kingdom <chr>, phylum <chr>, class <chr>, order <chr>, family <chr>,
#> #   genus <chr>, citation <chr>, lsid <chr>, isMarine <int>,
#> #   isBrackish <lgl>, isFreshwater <lgl>, isTerrestrial <lgl>,
#> #   isExtinct <int>, match_type <chr>, modified <chr>

by a taxonomic name

wm_records_name(name = 'Platanista gangetica')
#> # A tibble: 3 x 25
#>   AphiaID                                                           url
#> *   <int>                                                         <chr>
#> 1  254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967
#> 2  383571 http://www.marinespecies.org/aphia.php?p=taxdetails&id=383571
#> 3  254969 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254969
#> # ... with 23 more variables: scientificname <chr>, authority <chr>,
#> #   status <chr>, unacceptreason <lgl>, rank <chr>, valid_AphiaID <int>,
#> #   valid_name <chr>, valid_authority <chr>, kingdom <chr>, phylum <chr>,
#> #   class <chr>, order <chr>, family <chr>, genus <chr>, citation <chr>,
#> #   lsid <chr>, isMarine <int>, isBrackish <lgl>, isFreshwater <int>,
#> #   isTerrestrial <int>, isExtinct <lgl>, match_type <chr>, modified <chr>

by many names

wm_records_names(name = c('Platanista gangetica', 'Coryphaena'))
#> [[1]]
#> # A tibble: 1 x 25
#>   AphiaID                                                           url
#> *   <int>                                                         <chr>
#> 1  254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967
#> # ... with 23 more variables: scientificname <chr>, authority <chr>,
#> #   status <chr>, unacceptreason <lgl>, rank <chr>, valid_AphiaID <int>,
#> #   valid_name <chr>, valid_authority <chr>, kingdom <chr>, phylum <chr>,
#> #   class <chr>, order <chr>, family <chr>, genus <chr>, citation <chr>,
#> #   lsid <chr>, isMarine <lgl>, isBrackish <lgl>, isFreshwater <int>,
#> #   isTerrestrial <lgl>, isExtinct <lgl>, match_type <chr>, modified <chr>
#> 
#> [[2]]
#> # A tibble: 2 x 25
#>   AphiaID                                                           url
#> *   <int>                                                         <chr>
#> 1  125960 http://www.marinespecies.org/aphia.php?p=taxdetails&id=125960
#> 2  843430                                                          <NA>
#> # ... with 23 more variables: scientificname <chr>, authority <chr>,
#> #   status <chr>, unacceptreason <chr>, rank <chr>, valid_AphiaID <int>,
#> #   valid_name <chr>, valid_authority <chr>, kingdom <chr>, phylum <chr>,
#> #   class <chr>, order <chr>, family <chr>, genus <chr>, citation <chr>,
#> #   lsid <chr>, isMarine <int>, isBrackish <int>, isFreshwater <int>,
#> #   isTerrestrial <lgl>, isExtinct <lgl>, match_type <chr>, modified <chr>

by common name

wm_records_common(name = 'clam')
#> # A tibble: 2 x 25
#>   AphiaID                                                           url
#> *   <int>                                                         <chr>
#> 1  141919 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141919
#> 2  141936 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141936
#> # ... with 23 more variables: scientificname <chr>, authority <chr>,
#> #   status <chr>, unacceptreason <lgl>, rank <chr>, valid_AphiaID <int>,
#> #   valid_name <chr>, valid_authority <chr>, kingdom <chr>, phylum <chr>,
#> #   class <chr>, order <chr>, family <chr>, genus <chr>, citation <chr>,
#> #   lsid <chr>, isMarine <int>, isBrackish <lgl>, isFreshwater <lgl>,
#> #   isTerrestrial <lgl>, isExtinct <lgl>, match_type <chr>, modified <chr>

using the TAXMATCH algorithm

wm_records_taxamatch(name = 'Platanista gangetica')
#> [[1]]
#> # A tibble: 1 x 25
#>   AphiaID                                                           url
#> *   <int>                                                         <chr>
#> 1  254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967
#> # ... with 23 more variables: scientificname <chr>, authority <chr>,
#> #   status <chr>, unacceptreason <lgl>, rank <chr>, valid_AphiaID <int>,
#> #   valid_name <chr>, valid_authority <chr>, kingdom <chr>, phylum <chr>,
#> #   class <chr>, order <chr>, family <chr>, genus <chr>, citation <chr>,
#> #   lsid <chr>, isMarine <lgl>, isBrackish <lgl>, isFreshwater <int>,
#> #   isTerrestrial <lgl>, isExtinct <lgl>, match_type <chr>, modified <chr>

APHIA ID <–> name

wm_name2id(name = "Rhincodon")
#> [1] 105749
wm_id2name(id = 105706)
#> [1] "Rhincodontidae"

Get AphiaID via an external ID

wm_external(id = 1080)
#> [1] 85257
wm_external(id = 105706)
#> [1] 159854

Get vernacular names from an AphiaID

wm_common_id(id = 156806)
#> # A tibble: 2 x 3
#>            vernacular language_code language
#> *               <chr>         <chr>    <chr>
#> 1    gilded wedgeclam           eng  English
#> 2 Turton's wedge clam           eng  English

Children

Get direct taxonomic children for an AphiaID

wm_classification(id = 105706)
#> # A tibble: 11 x 3
#>    AphiaID       rank   scientificname
#>  *   <int>      <chr>            <chr>
#>  1       2    Kingdom         Animalia
#>  2    1821     Phylum         Chordata
#>  3  146419  Subphylum       Vertebrata
#>  4    1828 Superclass    Gnathostomata
#>  5   11676 Superclass           Pisces
#>  6   10193      Class   Elasmobranchii
#>  7  368407   Subclass      Neoselachii
#>  8  368408 Infraclass         Selachii
#>  9  368410 Superorder      Galeomorphi
#> 10   10208      Order Orectolobiformes
#> 11  105706     Family   Rhincodontidae

Classification

Get classification for an AphiaID

wm_classification(id = 105706)
#> # A tibble: 11 x 3
#>    AphiaID       rank   scientificname
#>  *   <int>      <chr>            <chr>
#>  1       2    Kingdom         Animalia
#>  2    1821     Phylum         Chordata
#>  3  146419  Subphylum       Vertebrata
#>  4    1828 Superclass    Gnathostomata
#>  5   11676 Superclass           Pisces
#>  6   10193      Class   Elasmobranchii
#>  7  368407   Subclass      Neoselachii
#>  8  368408 Infraclass         Selachii
#>  9  368410 Superorder      Galeomorphi
#> 10   10208      Order Orectolobiformes
#> 11  105706     Family   Rhincodontidae

Synonyms

Get synonyms for an AphiaID

wm_synonyms(id = 105706)
#> # A tibble: 1 x 25
#>   AphiaID                                                           url
#> *   <int>                                                         <chr>
#> 1  148832 http://www.marinespecies.org/aphia.php?p=taxdetails&id=148832
#> # ... with 23 more variables: scientificname <chr>, authority <chr>,
#> #   status <chr>, unacceptreason <chr>, rank <chr>, valid_AphiaID <int>,
#> #   valid_name <chr>, valid_authority <chr>, kingdom <chr>, phylum <chr>,
#> #   class <chr>, order <chr>, family <chr>, genus <lgl>, citation <chr>,
#> #   lsid <chr>, isMarine <lgl>, isBrackish <lgl>, isFreshwater <lgl>,
#> #   isTerrestrial <lgl>, isExtinct <lgl>, match_type <chr>, modified <chr>
worrms/inst/doc/worrms_vignette.Rmd0000644000176200001440000002127413147636503017245 0ustar liggesusers Introduction to the worrms package ================================== `worrms` is an R client for the [World Register of Marine Species](http://www.marinespecies.org/). ## Install Stable version from CRAN ```r install.packages("worrms") ``` Development version from GitHub ```r install.packages("devtools") devtools::install_github("ropensci/worrms") ``` ```r library("worrms") ``` ## Get records WoRMS 'records' are taxa, not specimen occurrences or something else. by date ```r wm_records_date('2016-12-23T05:59:45+00:00') #> # A tibble: 50 x 25 #> AphiaID url #> * #> 1 894298 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894298 #> 2 894301 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894301 #> 3 894297 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894297 #> 4 894302 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894302 #> 5 894296 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894296 #> 6 894299 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894299 #> 7 894303 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894303 #> 8 915236 http://www.marinespecies.org/aphia.php?p=taxdetails&id=915236 #> 9 906769 http://www.marinespecies.org/aphia.php?p=taxdetails&id=906769 #> 10 909454 http://www.marinespecies.org/aphia.php?p=taxdetails&id=909454 #> # ... with 40 more rows, and 23 more variables: scientificname , #> # authority , status , unacceptreason , rank , #> # valid_AphiaID , valid_name , valid_authority , #> # kingdom , phylum , class , order , family , #> # genus , citation , lsid , isMarine , #> # isBrackish , isFreshwater , isTerrestrial , #> # isExtinct , match_type , modified ``` by a taxonomic name ```r wm_records_name(name = 'Platanista gangetica') #> # A tibble: 3 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> 2 383571 http://www.marinespecies.org/aphia.php?p=taxdetails&id=383571 #> 3 254969 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254969 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` by many names ```r wm_records_names(name = c('Platanista gangetica', 'Coryphaena')) #> [[1]] #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified #> #> [[2]] #> # A tibble: 2 x 25 #> AphiaID url #> * #> 1 125960 http://www.marinespecies.org/aphia.php?p=taxdetails&id=125960 #> 2 843430 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` by common name ```r wm_records_common(name = 'clam') #> # A tibble: 2 x 25 #> AphiaID url #> * #> 1 141919 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141919 #> 2 141936 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141936 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` using the TAXMATCH algorithm ```r wm_records_taxamatch(name = 'Platanista gangetica') #> [[1]] #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` ## APHIA ID <--> name ```r wm_name2id(name = "Rhincodon") #> [1] 105749 ``` ```r wm_id2name(id = 105706) #> [1] "Rhincodontidae" ``` ## Get AphiaID via an external ID ```r wm_external(id = 1080) #> [1] 85257 wm_external(id = 105706) #> [1] 159854 ``` ## Get vernacular names from an AphiaID ```r wm_common_id(id = 156806) #> # A tibble: 2 x 3 #> vernacular language_code language #> * #> 1 gilded wedgeclam eng English #> 2 Turton's wedge clam eng English ``` ## Children Get direct taxonomic children for an AphiaID ```r wm_classification(id = 105706) #> # A tibble: 11 x 3 #> AphiaID rank scientificname #> * #> 1 2 Kingdom Animalia #> 2 1821 Phylum Chordata #> 3 146419 Subphylum Vertebrata #> 4 1828 Superclass Gnathostomata #> 5 11676 Superclass Pisces #> 6 10193 Class Elasmobranchii #> 7 368407 Subclass Neoselachii #> 8 368408 Infraclass Selachii #> 9 368410 Superorder Galeomorphi #> 10 10208 Order Orectolobiformes #> 11 105706 Family Rhincodontidae ``` ## Classification Get classification for an AphiaID ```r wm_classification(id = 105706) #> # A tibble: 11 x 3 #> AphiaID rank scientificname #> * #> 1 2 Kingdom Animalia #> 2 1821 Phylum Chordata #> 3 146419 Subphylum Vertebrata #> 4 1828 Superclass Gnathostomata #> 5 11676 Superclass Pisces #> 6 10193 Class Elasmobranchii #> 7 368407 Subclass Neoselachii #> 8 368408 Infraclass Selachii #> 9 368410 Superorder Galeomorphi #> 10 10208 Order Orectolobiformes #> 11 105706 Family Rhincodontidae ``` ## Synonyms Get synonyms for an AphiaID ```r wm_synonyms(id = 105706) #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 148832 http://www.marinespecies.org/aphia.php?p=taxdetails&id=148832 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` worrms/tests/0000755000176200001440000000000013147642434012755 5ustar liggesusersworrms/tests/testthat/0000755000176200001440000000000013147642434014615 5ustar liggesusersworrms/tests/testthat/test-wm_distribution.R0000644000176200001440000000211413147633205021131 0ustar liggesuserscontext("wm_distribution") test_that("wm_distribution basic usage works", { skip_on_cran() aa <- wm_distribution(id = 156806) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_gt(NROW(aa), 1) }) test_that("wm_distribution fails well", { skip_on_cran() expect_error(wm_distribution(), "argument \"id\" is missing") expect_error(wm_distribution("asdfafasdfs"), "id must be of class") expect_error(wm_distribution(44444), "\\(204\\) No Content") }) context("wm_distribution_ - plural") test_that("wm_distribution_ basic usage works", { skip_on_cran() aa <- wm_distribution_(id = 156806) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_gt(NROW(aa), 1) bb <- wm_distribution_(id = c(156806, 126436)) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_gt(NROW(bb), NROW(aa)) }) test_that("wm_distribution_ fails well", { skip_on_cran() expect_error(wm_distribution_(), "use only one of") expect_error(wm_distribution_("asdfafasdfs"), "id must be of class") expect_error(wm_distribution_(44444), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_records_taxamatch.R0000644000176200001440000000135713027323324022110 0ustar liggesuserscontext("wm_records_taxamatch") test_that("wm_records_taxamatch basic usage works", { skip_on_cran() aa <- wm_records_taxamatch(name = 'Platanista gangetica') expect_is(aa, "list") expect_equal(length(aa), 1) expect_is(aa[[1]], "tbl_df") expect_is(aa[[1]], "data.frame") expect_equal(NROW(aa[[1]]), 1) }) test_that("wm_records_taxamatch fails well", { skip_on_cran() expect_error(wm_records_taxamatch(), "argument \"name\" is missing") expect_error(wm_records_taxamatch("asdfafasdfs"), "No Content") expect_error(wm_records_taxamatch(5), "name must be of class character") expect_error(wm_records_taxamatch('Platanista gangetica', marine_only = 5), "marine_only must be of class logical") }) worrms/tests/testthat/test-wm_records_names.R0000644000176200001440000000203213035052410021222 0ustar liggesuserscontext("wm_records_names") test_that("wm_records_names - works", { skip_on_cran() aa <- wm_records_names(name = 'Platanista gangetica') expect_is(aa, "list") expect_is(aa[[1]], "tbl_df") expect_is(aa[[1]], "data.frame") expect_true(all(grepl("Platanista", aa[[1]]$scientificname))) expect_equal(NROW(aa[[1]]), 1) }) test_that("wm_records_names - fuzzy parameter", { skip_on_cran() aa <- wm_records_names(name = 'Platanista gangetica', fuzzy = TRUE) expect_is(aa, "list") expect_is(aa[[1]], "tbl_df") expect_is(aa[[1]], "data.frame") expect_true(all(grepl("Platanista", aa[[1]]$scientificname))) expect_gt(NROW(aa[[1]]), 1) }) test_that("wm_records_names fails well", { skip_on_cran() expect_error(wm_records_names(), "argument \"name\" is missing") expect_error(wm_records_names(55555), "name must be of class character") expect_error(wm_records_names("asdfs", "Adf"), "fuzzy must be of class logical") expect_error(wm_records_names("asdfs", marine_only = 5), "marine_only must be of class logical") }) worrms/tests/testthat/test-wm_name2id.R0000644000176200001440000000204113147633205017730 0ustar liggesuserscontext("wm_name2id") test_that("wm_name2id - default usage works", { skip_on_cran() aa <- wm_name2id(name = "Rhincodon") expect_type(aa, "integer") expect_equal(aa, 105749) }) test_that("wm_name2id fails well", { skip_on_cran() expect_error(wm_name2id(), "argument \"name\" is missing") expect_error(wm_name2id(44444), "name must be of class") expect_error(wm_name2id("asdfafasdfs"), "\\(204\\) No Content") }) context("wm_name2id_ - plural") test_that("wm_name2id_ - default usage works", { skip_on_cran() aa <- wm_name2id_(name = "Rhincodon") expect_type(aa, "list") expect_named(aa, "Rhincodon") bb <- wm_name2id_(name = c("Rhincodon", "Gadus morhua")) expect_type(bb, "list") expect_type(bb[[1]], "integer") expect_named(bb, c("Rhincodon", "Gadus morhua")) }) test_that("wm_name2id_ fails well", { skip_on_cran() expect_error(wm_name2id_(), "argument \"name\" is missing") expect_error(wm_name2id_(44444), "name must be of class") expect_error(wm_name2id_("asdfafasdfs"), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_id2name.R0000644000176200001440000000203313147633205017731 0ustar liggesuserscontext("wm_id2name") test_that("wm_id2name - default usage works", { skip_on_cran() aa <- wm_id2name(id = 1080) expect_type(aa, "character") expect_equal(aa, "Copepoda") }) test_that("wm_id2name fails well", { skip_on_cran() expect_error(wm_id2name(), "argument \"id\" is missing") expect_error(wm_id2name("asdfafasdfs"), "id must be of class") expect_error(wm_id2name(44444), "\\(204\\) No Content") }) context("wm_id2name_ - plural") test_that("wm_id2name_ - default usage works", { skip_on_cran() aa <- wm_id2name_(id = 1080) expect_type(aa, "list") expect_type(aa[[1]], "character") expect_equal(aa[[1]], "Copepoda") bb <- wm_id2name_(id = c(105706, 126436)) expect_type(bb, "list") expect_equal(length(bb), 2) expect_named(bb, c('105706', '126436')) }) test_that("wm_id2name_ fails well", { skip_on_cran() expect_error(wm_id2name_(), "argument \"id\" is missing") expect_error(wm_id2name_("asdfafasdfs"), "id must be of class") expect_error(wm_id2name_(44444), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_common_id.R0000644000176200001440000000244713147633205020367 0ustar liggesuserscontext("wm_common_id") test_that("wm_common_id basic usage works", { skip_on_cran() aa <- wm_common_id(id = 156806) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_named(aa, c('vernacular', 'language_code', 'language')) expect_match(aa$vernacular, "clam") }) test_that("wm_common_id fails well", { skip_on_cran() expect_error(wm_common_id(), "argument \"id\" is missing") expect_error(wm_common_id("asdfafasdfs"), "id must be of class") expect_error(wm_common_id(44444), "\\(204\\) No Content") }) context("wm_common_id_ - plural") test_that("wm_common_id_ basic usage works", { skip_on_cran() # singular aa <- wm_common_id_(id = 156806) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_named(aa, c('id', 'vernacular', 'language_code', 'language')) expect_match(aa$vernacular, "clam") # plural bb <- wm_common_id_(id = c(105706, 156806, 397065)) expect_is(bb, "tbl_df") expect_is(bb, "data.frame") expect_named(bb, c('id', 'vernacular', 'language_code', 'language')) expect_gt(NROW(bb), NROW(aa)) }) test_that("wm_common_id_ fails well", { skip_on_cran() expect_error(wm_common_id_(), "use only one of") expect_error(wm_common_id_("asdfafasdfs"), "id must be of class") expect_error(wm_common_id_(44444), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_external.R0000644000176200001440000000223413147633205020237 0ustar liggesuserscontext("wm_external") test_that("wm_external - default usage works", { skip_on_cran() aa <- wm_external(id = 1080) expect_type(aa, "integer") expect_equal(aa, 85257) }) test_that("wm_external - type: fishbase", { skip_on_cran() aa <- wm_external(id = 278468, type = "fishbase") expect_type(aa, "integer") expect_equal(aa, 8399) }) test_that("wm_external fails well", { skip_on_cran() expect_error(wm_external(), "argument \"id\" is missing") expect_error(wm_external("asdfafasdfs"), "id must be of class") expect_error(wm_external(44444), "\\(204\\) No Content") }) context("wm_external_ - plural") test_that("wm_external_ - default usage works", { skip_on_cran() aa <- wm_external_(id = 1080) expect_type(aa, "list") expect_type(aa[[1]], "integer") expect_equal(aa[[1]], 85257) bb <- wm_external_(id = c(1080, 126436)) expect_type(bb, "list") expect_named(bb, c('1080', '126436')) }) test_that("wm_external_ fails well", { skip_on_cran() expect_error(wm_external_(), "use only one of") expect_error(wm_external_("asdfafasdfs"), "id must be of class") expect_error(wm_external_(44444), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_records_common.R0000644000176200001440000000334613147633205021433 0ustar liggesuserscontext("wm_records_common") test_that("wm_records_common - works", { skip_on_cran() aa <- wm_records_common(name = 'dolphin') expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true(any(grepl("AphiaID", names(aa)))) expect_equal(aa$kingdom, "Animalia") expect_equal(aa$genus, "Coryphaena") }) test_that("wm_records_common - fuzzy parameter works", { skip_on_cran() aa <- wm_records_common(name = 'dolphin') bb <- wm_records_common(name = 'dolphin', fuzzy = TRUE) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_is(bb, "tbl_df") expect_is(bb, "data.frame") expect_gt(NROW(bb), NROW(aa)) }) test_that("wm_records_common - offset parameter works", { skip_on_cran() aa <- wm_records_common(name = 'dolphin', fuzzy = TRUE) bb <- wm_records_common(name = 'dolphin', fuzzy = TRUE, offset = 10) expect_false(identical(aa$AphiaID, bb$AphiaID)) }) test_that("wm_records_common fails well", { skip_on_cran() expect_error(wm_records_common(), "argument \"name\" is missing") expect_error(wm_records_common(55555), "name must be of class character") expect_error(wm_records_common("asdfafasdfs"), "\\(204\\) No Content") }) context("wm_records_common_ - plural") test_that("wm_records_common_ - works", { skip_on_cran() bb <- wm_records_common_(name = c('dolphin', 'clam')) expect_is(bb, "tbl_df") expect_is(bb, "data.frame") expect_true("dolphin" %in% bb$id) expect_true("clam" %in% bb$id) }) test_that("wm_records_common_ fails well", { skip_on_cran() expect_error(wm_records_common_(), "argument \"name\" is missing") expect_error(wm_records_common_(55555), "name must be of class character") expect_error(wm_records_common_("asdfafasdfs"), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_record.R0000644000176200001440000000210013147633205017663 0ustar liggesuserscontext("wm_record") test_that("wm_record - default usage works", { skip_on_cran() aa <- wm_record(id = 105706) expect_type(aa, "list") expect_equal(aa$valid_name, "Rhincodontidae") expect_equal(aa$valid_AphiaID, 105706) }) test_that("wm_record fails well", { skip_on_cran() expect_error(wm_record(), "argument \"id\" is missing") expect_error(wm_record("asdfafasdfs"), "id must be of class") expect_error(wm_record(44444), "\\(204\\) No Content") }) context("wm_record_ - plural") test_that("wm_record_ - default usage works", { skip_on_cran() aa <- wm_record_(id = 105706) expect_type(aa, "list") expect_equal(aa$`105706`$valid_name, "Rhincodontidae") expect_equal(aa$`105706`$valid_AphiaID, 105706) bb <- wm_record_(id = c(105706, 126436)) expect_type(bb, "list") expect_named(bb, c('105706', '126436')) }) test_that("wm_record_ fails well", { skip_on_cran() expect_error(wm_record_(), "use only one of") expect_error(wm_record_("asdfafasdfs"), "id must be of class") expect_error(wm_record_(44444), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_records_name.R0000644000176200001440000000204113035052147021046 0ustar liggesuserscontext("wm_records_name") test_that("wm_records_name - works", { skip_on_cran() aa <- wm_records_name(name = 'Platanista gangetica') expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true(all(grepl("Platanista", aa$scientificname))) expect_gt(NROW(aa), 1) }) test_that("wm_records_name - fuzzy parameter", { skip_on_cran() aa <- wm_records_name(name = 'Platanista gangetica', fuzzy = FALSE) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true(all(grepl("Platanista", aa$scientificname))) expect_equal(NROW(aa), 1) }) test_that("wm_records_name fails well", { skip_on_cran() expect_error(wm_records_name(), "argument \"name\" is missing") expect_error(wm_records_name(55555), "name must be of class character") expect_error(wm_records_name("asdfs", "Adf"), "fuzzy must be of class logical") expect_error(wm_records_name("asdfs", marine_only = 5), "marine_only must be of class logical") expect_error(wm_records_name("asdfs", offset = "foobar"), "offset must be of class numeric, integer") }) worrms/tests/testthat/test-wm_children.R0000644000176200001440000000414713147633205020212 0ustar liggesuserscontext("wm_children") test_that("wm_children basic usage works", { skip_on_cran() aa <- wm_children(id = 105706) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_gt(NROW(aa), 1) expect_equal(unique(aa$family), "Rhincodontidae") expect_equal(unique(aa$order), "Orectolobiformes") expect_equal(unique(aa$class), "Elasmobranchii") expect_equal(unique(aa$phylum), "Chordata") expect_equal(unique(aa$kingdom), "Animalia") }) test_that("wm_children - marine_only usage works", { skip_on_cran() expect_is(wm_children(id = 105706, FALSE), "tbl_df") expect_is(wm_children(id = 105706, TRUE), "tbl_df") }) test_that("wm_children - offset parameter works", { skip_on_cran() off1 <- wm_children(id = 105706, offset = 1) off2 <- wm_children(id = 105706, offset = 2) expect_equal(off1$AphiaID[1], 297110) expect_equal(off2$AphiaID[1], 398065) }) test_that("wm_children fails well", { skip_on_cran() expect_error(wm_children(), "argument \"id\" is missing") expect_error(wm_children("asdfafasdfs"), "id must be of class") expect_error(wm_children(44444), "\\(204\\) No Content") }) ## plural methods context("wm_children_ - plural") test_that("wm_children_ basic usage works", { skip_on_cran() # works for singleton input aa <- wm_children_(id = 254966) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_gt(NROW(aa), 1) expect_equal(unique(aa$family), "Platanistidae") # works for >1 input bb <- wm_children_(id = c(254966, 343613)) expect_is(bb, "tbl_df") expect_is(bb, "data.frame") expect_gt(NROW(bb), NROW(aa)) }) test_that("wm_children_ - 'name' input works", { skip_on_cran() aa <- wm_children_(name = c('Platanista', 'Leucophaeus')) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true(any(grepl('Platanista', aa$scientificname))) expect_true(any(grepl('Leucophaeus', aa$scientificname))) }) test_that("wm_children_ fails well", { skip_on_cran() expect_error(wm_children_(), "use only one of") expect_error(wm_children_("asdfafasdfs"), "id must be of class") expect_error(wm_children_(44444), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_classification.R0000644000176200001440000000230113147633205021403 0ustar liggesuserscontext("wm_classification") test_that("wm_classification works", { skip_on_cran() aa <- wm_classification(id = 105706) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_named(aa, c('AphiaID', 'rank', 'scientificname')) }) test_that("wm_classification fails well", { skip_on_cran() expect_error(wm_classification(), "argument \"id\" is missing") expect_error(wm_classification("asdfafasdfs"), "id must be of class") bb <- wm_classification(23424234) expect_equal(NROW(bb), 0) expect_equal(length(names(bb)), 0) }) context("wm_classification - plural") test_that("wm_classification_ works", { skip_on_cran() # singular works aa <- wm_classification_(id = 105706) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_named(aa, c('id', 'AphiaID', 'rank', 'scientificname')) # many works bb <- wm_classification_(id = c(254967, 344089)) expect_is(bb, "tbl_df") expect_is(bb, "data.frame") expect_named(bb, c('id', 'AphiaID', 'rank', 'scientificname')) }) test_that("wm_classification_ fails well", { skip_on_cran() expect_error(wm_classification_(), "use only one of") expect_error(wm_classification_("asdfafasdfs"), "id must be of class") }) worrms/tests/testthat/test-wm_synonyms.R0000644000176200001440000000206613147633205020317 0ustar liggesuserscontext("wm_synonyms") test_that("wm_synonyms - works", { skip_on_cran() aa <- wm_synonyms(id = 105706) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_equal(NROW(aa), 1) expect_true(any(grepl("scientificname", names(aa)))) expect_true(any(grepl("AphiaID", names(aa)))) expect_true(any(grepl("valid_AphiaID", names(aa)))) expect_true(any(grepl("valid_name", names(aa)))) expect_true(any(grepl("valid_authority", names(aa)))) }) test_that("wm_synonyms fails well", { skip_on_cran() expect_error(wm_synonyms(), "argument \"id\" is missing") expect_error(wm_synonyms(55555), "\\(204\\) No Content") }) context("wm_synonyms_ - plural") test_that("wm_synonyms_ - works", { skip_on_cran() aa <- wm_synonyms_(id = c(105706, 126436)) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true('105706' %in% aa$id) expect_true('126436' %in% aa$id) }) test_that("wm_synonyms_ fails well", { skip_on_cran() expect_error(wm_synonyms_(), "use only one of") expect_error(wm_synonyms_(55555), "\\(204\\) No Content") }) worrms/tests/testthat/test-wm_record_by_external.R0000644000176200001440000000300513147633205022264 0ustar liggesuserscontext("wm_record_by_external") test_that("wm_record_by_external - default - by id type tsn", { skip_on_cran() # tsn tsn <- wm_record_by_external(id = 85257) expect_type(tsn, "list") expect_equal(tsn$valid_name, "Copepoda") expect_equal(tsn$valid_AphiaID, 1080) # ncbi ncbi <- wm_record_by_external(id = 6830, type = "ncbi") expect_type(ncbi, "list") expect_equal(ncbi$valid_name, "Copepoda") expect_equal(ncbi$valid_AphiaID, 1080) # they're equivvalent expect_identical(tsn, ncbi) # fishbase fishbase <- wm_record_by_external(id = 8399, type = "fishbase") expect_type(fishbase, "list") expect_equal(fishbase$valid_name, "Callorhinchus callorynchus") expect_equal(fishbase$valid_AphiaID, 278468) }) test_that("wm_record_by_external fails well", { skip_on_cran() expect_error(wm_record_by_external(), "argument \"id\" is missing") expect_error(wm_record_by_external("asdfafasdfs"), "id must be of class") }) context("wm_record_by_external_ - plural") test_that("wm_record_by_external_ - default - by id type tsn", { skip_on_cran() # singluar tsn <- wm_record_by_external_(id = 85257) expect_type(tsn, "list") expect_named(tsn, "85257") # many bb <- wm_record_by_external_(id = c(85257, 159854)) expect_is(bb, "list") expect_named(bb, c("85257", "159854")) }) test_that("wm_record_by_external_ fails well", { skip_on_cran() expect_error(wm_record_by_external_(), "use only one of") expect_error(wm_record_by_external_("asdfafasdfs"), "id must be of class") }) worrms/tests/testthat/test-wm_records_date.R0000644000176200001440000000076613147632241021062 0ustar liggesuserscontext("wm_records_date") test_that("wm_records_date - works", { skip_on_cran() a_date <- format(Sys.Date() - 1, "%Y-%m-%dT%H:%M:%S+00:00") aa <- wm_records_date(a_date) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true(all(grepl("2017", aa$modified))) }) test_that("wm_records_date fails well", { skip_on_cran() expect_error(wm_records_date(), "argument \"start_date\" is missing") expect_error(wm_records_date(55555), "start_date must be of class character") }) worrms/tests/testthat/test-wm_sources.R0000644000176200001440000000167413147633205020107 0ustar liggesuserscontext("wm_sources") test_that("wm_sources - works", { skip_on_cran() aa <- wm_sources(id = 105706) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true(any(grepl("use", names(aa)))) expect_true(any(grepl("reference", names(aa)))) expect_true(any(grepl("page", names(aa)))) expect_true(any(grepl("url", names(aa)))) }) test_that("wm_sources fails well", { skip_on_cran() expect_error(wm_sources(), "argument \"id\" is missing") expect_error(wm_sources(55555), "\\(204\\) No Content") }) context("wm_sources_ - plural") test_that("wm_sources_ - works", { skip_on_cran() aa <- wm_sources_(id = c(105706, 126436)) expect_is(aa, "tbl_df") expect_is(aa, "data.frame") expect_true('105706' %in% aa$id) expect_true('126436' %in% aa$id) }) test_that("wm_sources_ fails well", { skip_on_cran() expect_error(wm_sources_(), "use only one of") expect_error(wm_sources_(55555), "\\(204\\) No Content") }) worrms/tests/test-all.R0000644000176200001440000000005113027321070014604 0ustar liggesuserslibrary("testthat") test_check("worrms") worrms/NAMESPACE0000644000176200001440000000125413147633205013030 0ustar liggesusers# Generated by roxygen2: do not edit by hand export(wm_children) export(wm_children_) export(wm_classification) export(wm_classification_) export(wm_common_id) export(wm_common_id_) export(wm_distribution) export(wm_distribution_) export(wm_external) export(wm_external_) export(wm_id2name) export(wm_id2name_) export(wm_name2id) export(wm_name2id_) export(wm_record) export(wm_record_) export(wm_record_by_external) export(wm_record_by_external_) export(wm_records_common) export(wm_records_common_) export(wm_records_date) export(wm_records_name) export(wm_records_names) export(wm_records_taxamatch) export(wm_sources) export(wm_sources_) export(wm_synonyms) export(wm_synonyms_) worrms/NEWS.md0000644000176200001440000000112513147640051012701 0ustar liggesusersworrms 0.2.0 ============ ### NEW FEATURES * Added additional sister functions to most exported functions in the package, all with trailing underscore. For example, `wm_children` and `wm_children_`. These underscore methods take in many inputs, typically of a AphiaID or a taxonomic or vernacular name. We decided to make separate functions so that we minimize any disturbance to the existing package API. (#4) (#6) ## MINOR IMPROVEMENTS * Moved to using markdown docs (#5) * All functions now state what they return (#9) worrms 0.1.0 ============ ### NEW FEATURES * Released to CRAN. worrms/R/0000755000176200001440000000000013147642434012014 5ustar liggesusersworrms/R/wm_records_date.R0000644000176200001440000000164113147640306015276 0ustar liggesusers#' Get records by date #' #' @export #' @param start_date (character) start date. required. #' @param end_date (character) end date. optional #' @param marine_only (logical) marine only or not. default: `TRUE` #' @param offset (integer) record to start at. default: 1 #' @template curl #' @return A tibble/data.frame #' @examples \dontrun{ #' a_date <- format(Sys.Date() - 1, "%Y-%m-%dT%H:%M:%S+00:00") #' wm_records_date(a_date) #' } wm_records_date <- function(start_date, end_date = NULL, marine_only = TRUE, offset = 1, ...) { assert(start_date, c("character", "Date")) assert(end_date, c("character", "Date")) assert(marine_only, "logical") assert(offset, c('numeric', 'integer')) wm_GET(file.path(wm_base(), "AphiaRecordsByDate"), query = cc(list( startdate = start_date, enddate = end_date, marine_only = as_log(marine_only), offset = offset)), ...) } worrms/R/wm_record_by_external.R0000644000176200001440000000226413147640322016512 0ustar liggesusers#' Get record by external ID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_record_by_external` #' it's required and must be `length(id) = 1`, for #' `wm_record_by_external_` it's optional and can be `length(id) >= 1` #' @param type (character) the type of external id. one of: tsn, bold, #' dyntaxa, eol, fishbase, iucn, lsid, ncbi, gisd. default: tsn #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A named list. When using underscore method, each output is named #' by the input ID, and can be separated by the list names #' @examples \dontrun{ #' wm_record_by_external(id = 85257) #' wm_record_by_external(id = 159854) #' #' wm_record_by_external_(id = c(85257, 159854)) #' } wm_record_by_external <- function(id, type = "tsn", ...) { assert(id, c("numeric", "integer")) assert(type, "character") wm_GET(file.path(wm_base(), "AphiaRecordByExternalID", id), query = cc(list(type = type)), ...) } #' @export #' @rdname wm_record_by_external wm_record_by_external_ <- function(id = NULL, name = NULL, type = "tsn", ...) { id <- id_name(id, name) run_c(id, wm_record_by_external, type = type, ...) } worrms/R/wm_records_common.R0000644000176200001440000000262713147640315015656 0ustar liggesusers#' Get records by vernacular name, optional fuzzy matching #' #' @export #' @param name (character) a species common name. required. For #' `wm_records_common` must be `length(id) = 1`; for `wm_records_common_` #' can be `length(id) >= 1` #' @param fuzzy (logical) fuzzy search. default: `FALSE` #' @param offset (integer) record to start at. default: 1 #' @template curl #' @template plural #' @return A tibble/data.frame. when using underscore method, outputs from #' each input are binded together, but can be split by `id` column #' @examples \dontrun{ #' wm_records_common(name = 'dolphin') #' wm_records_common(name = 'clam') #' #' wm_records_common_(name = c('dolphin', 'clam')) #' #' wm_records_common(name = 'dolphin', fuzzy = TRUE) #' wm_records_common(name = 'clam', fuzzy = TRUE, offset = 5) #' } wm_records_common <- function(name, fuzzy = FALSE, offset = 1, ...) { assert(name, "character") assert(fuzzy, "logical") assert(offset, c('numeric', 'integer')) if (length(name) > 1) stop("'name' must be of length 1", call. = FALSE) args <- cc(list( like = as_log(fuzzy), offset = offset )) wm_GET(file.path(wm_base(), "AphiaRecordsByVernacular", name), query = args, ...) } #' @export #' @rdname wm_records_common wm_records_common_ <- function(name, fuzzy = FALSE, offset = 1, ...) { run_bind(name, wm_records_common, fuzzy = fuzzy, offset = offset, ...) } worrms/R/wm_synonyms.R0000644000176200001440000000156113147640262014541 0ustar liggesusers#' Get synonyms for an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_synonyms` it's required #' and must be `length(id) = 1`, for `wm_synonyms_` it's optional and #' can be `length(id) >= 1` #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A tibble/data.frame. when using underscore method, outputs from #' each input are binded together, but can be split by `id` column #' @examples \dontrun{ #' wm_synonyms(id = 105706) #' wm_synonyms_(id = 105706) #' wm_synonyms_(id = c(105706, 126436)) #' } wm_synonyms <- function(id, ...) { assert(id, c("numeric", "integer")) wm_GET(file.path(wm_base(), "AphiaSynonymsByAphiaID", id), ...) } #' @export #' @rdname wm_synonyms wm_synonyms_ <- function(id = NULL, name = NULL, ...) { id <- id_name(id, name) run_bind(id, wm_synonyms, ...) } worrms/R/wm_distribution.R0000644000176200001440000000164113147640351015357 0ustar liggesusers#' Get distribution data by AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_distribution` it's #' required and must be `length(id) = 1`, for `wm_distribution_` it's #' optional and can be `length(id) >= 1` #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A tibble/data.frame. when using underscore method, outputs from #' each input are binded together, but can be split by `id` column #' @examples \dontrun{ #' wm_distribution(id = 156806) #' wm_distribution(id = 126436) #' #' wm_distribution_(id = c(156806, 126436)) #' } wm_distribution <- function(id, ...) { assert(id, c("numeric", "integer")) wm_GET(file.path(wm_base(), "AphiaDistributionsByAphiaID", id), ...) } #' @export #' @rdname wm_distribution wm_distribution_ <- function(id = NULL, name = NULL, ...) { id <- id_name(id, name) run_bind(id, wm_distribution, ...) } worrms/R/wm_id2name.R0000644000176200001440000000131413147640340014152 0ustar liggesusers#' Get taxonomic name for an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID, required. For `wm_id2name` #' must be `length(id) = 1`, but for `wm_id2name_` can be #' `length(id) >= 1` #' @template curl #' @template plural #' @return An character string that is the taxnomic name. When using underscore #' method, a list, named by the input IDs #' @examples \dontrun{ #' wm_id2name(id = 105706) #' wm_id2name_(id = c(105706, 126436)) #' } wm_id2name <- function(id, ...) { assert(id, c("numeric", "integer")) wm_GET(file.path(wm_base(), "AphiaNameByAphiaID", id), ...) } #' @export #' @rdname wm_id2name wm_id2name_ <- function(id, ...) { id <- id_name(id, NULL) run_c(id, wm_id2name, ...) } worrms/R/wm_sources.R0000644000176200001440000000164113147640271014324 0ustar liggesusers#' Get sources for an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_sources` it's required #' and must be `length(id) = 1`, for `wm_sources_` it's optional and #' can be `length(id) >= 1` #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A tibble/data.frame. when using underscore method, outputs from #' each input are binded together, but can be split by `id` column #' @examples \dontrun{ #' wm_sources(id = 105706) #' wm_sources_(id = 105706) #' wm_sources_(id = c(105706, 126436)) #' wm_sources_(name = c("Rhincodontidae", "Gadus morhua")) #' } wm_sources <- function(id, ...) { assert(id, c("numeric", "integer")) wm_GET(file.path(wm_base(), "AphiaSourcesByAphiaID", id), ...) } #' @export #' @rdname wm_sources wm_sources_ <- function(id = NULL, name = NULL, ...) { id <- id_name(id, name) run_bind(id, wm_sources, ...) } worrms/R/wm_externalid.R0000644000176200001440000000257213147640345015006 0ustar liggesusers#' Get an external ID via an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_external` it's #' required and must be `length(id) = 1`, for `wm_external_` it's #' optional and can be `length(id) >= 1` #' @param type (character) the type of external id. one of: tsn, bold, #' dyntaxa, eol, fishbase, iucn, lsid, ncbi, gisd. default: tsn #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return An integer that is the ID. When using underscore method, #' a list, named by the input IDs #' @examples \dontrun{ #' # by default, get a TSN (an ITIS code) #' wm_external(id = 1080) #' #' ## get many #' wm_external_(id = c(1080, 126436)) #' #' # BOLD code #' wm_external(id = 278468, type = "bold") #' #' # NCBI code #' wm_external(id = 278468, type = "ncbi") #' #' # fishbase code #' wm_external(id = 278468, type = "fishbase") #' #' # curl options #' library(crul) #' wm_external(id = 105706, verbose = TRUE) #' } wm_external <- function(id, type = "tsn", ...) { assert(id, c("numeric", "integer")) assert(type, "character") as.integer(wm_GET( file.path(wm_base(), "AphiaExternalIDByAphiaID", id), query = cc(list(type = type)), ...)) } #' @export #' @rdname wm_external wm_external_ <- function(id = NULL, name = NULL, type = "tsn", ...) { id <- id_name(id, name) run_c(id, wm_external, type = type, ...) } worrms/R/wm_record.R0000644000176200001440000000150413147640332014113 0ustar liggesusers#' Get complete AphiaRecord for an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_record` it's #' required and must be `length(id) = 1`, for `wm_record_` it's #' optional and can be `length(id) >= 1` #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A named list. When using underscore method, each output is named #' by the input ID, and can be separated by the list names #' @examples \dontrun{ #' wm_record(id = 105706) #' wm_record_(id = c(105706, 126436)) #' } wm_record <- function(id, ...) { assert(id, c("numeric", "integer")) wm_GET(file.path(wm_base(), "AphiaRecordByAphiaID", id), ...) } #' @export #' @rdname wm_record wm_record_ <- function(id = NULL, name = NULL, ...) { id <- id_name(id, name) run_c(id, wm_record, ...) } worrms/R/wm_records_names.R0000644000176200001440000000221513147640276015470 0ustar liggesusers#' Get records for onen or more taxonomic name(s) #' #' @export #' @param name (character) start date. required. #' @param fuzzy (logical) fuzzy search. default: `FALSE` #' @param marine_only (logical) marine only or not. default: `TRUE` #' @template curl #' @note there is no underscore method like other functions in this package #' as this is the plural version for [wm_records_name()] #' @return A list of tibble's/data.frame's, one for each of the input names #' @examples \dontrun{ #' wm_records_names(name = 'Platanista gangetica') #' wm_records_names(name = 'Platanista gangetica', fuzzy = TRUE) #' wm_records_names(name = c('Platanista gangetica', 'Coryphaena')) #' } wm_records_names <- function(name, fuzzy = FALSE, marine_only = TRUE, ...) { assert(name, "character") assert(fuzzy, "logical") assert(marine_only, "logical") args <- cc(list(like = as_log(fuzzy), marine_only = as_log(marine_only))) args <- c(args, stats::setNames(as.list(name), rep('scientificnames[]', length(name)))) wm_GET(file.path(wm_base(), "AphiaRecordsByNames"), query = args, ...) } worrms/R/worrms-package.R0000644000176200001440000000112013147634117015052 0ustar liggesusers#' World Register of Marine Species Client #' #' @name worrms-package #' @aliases worrms #' @docType package #' @keywords package #' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} #' #' @section Fail behavior: #' The WoRMS REST API doesn't have sophisticated error messaging, so #' most errors will result in a `(204) - No Content` or #' in `(400) - Bad Request` #' #' Because WoRMS doesn't do comprehensive error reporting, we do a fair #' amount of checking user inputs to help prevent errors that will be #' meaningless to the user. Let us know if we can improve on this. NULL worrms/R/wm_records_taxamatch.R0000644000176200001440000000201213147635777016344 0ustar liggesusers#' Get records for onen or more taxonomic name(s) using #' the TAXAMATCH fuzzy matching algorithm #' #' @export #' @param name (character) taxon name. required. #' @param marine_only (logical) marine only or not. default: `TRUE` #' @template curl #' @note there is no underscore method like other functions in this package #' as this function already accepts many names #' @return A list of tibble's/data.frame's, one for each of the input names #' @examples \dontrun{ #' wm_records_taxamatch(name = 'Platanista gangetica') #' wm_records_taxamatch(name = c('Platanista gangetica', 'Coryphaena')) #' } wm_records_taxamatch <- function(name, marine_only = TRUE, ...) { assert(name, "character") assert(marine_only, "logical") args <- cc(list(marine_only = as_log(marine_only))) args <- c(args, stats::setNames(as.list(name), rep('scientificnames[]', length(name)))) wm_GET(file.path(wm_base(), "AphiaRecordsByMatchNames"), query = args, ...) } worrms/R/wm_children.R0000644000176200001440000000274413147640367014444 0ustar liggesusers#' Get children for an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_children` it's #' required and must be `length(id) = 1`, for `wm_children_` it's #' optional and can be `length(id) >= 1` #' @param marine_only (logical) marine only or not. default: `TRUE` #' @param offset (integer) record to start at. default: 1 #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A tibble/data.frame. when using underscore method, outputs from #' each input are binded together, but can be split by `id` column #' @examples \dontrun{ #' wm_children(id = 105706) #' wm_children(id = 105706, FALSE) #' wm_children(id = 105706, offset = 5) #' #' wm_children(254966) #' wm_children(343613) #' #' # plural version, via id or name #' wm_children_(id = c(254966, 343613)) #' wm_children_(name = c('Platanista', 'Leucophaeus')) #' } wm_children <- function(id, marine_only = TRUE, offset = 1, ...) { assert(id, c("numeric", "integer")) assert(marine_only, "logical") assert(offset, c("numeric", "integer")) wm_GET(file.path(wm_base(), "AphiaChildrenByAphiaID", id), query = cc(list(marine_only = as_log(marine_only), offset = offset)), ...) } #' @export #' @rdname wm_children wm_children_ <- function(id = NULL, name = NULL, marine_only = TRUE, offset = 1, ...) { id <- id_name(id, name) run_bind(id, wm_children, marine_only = marine_only, offset = offset, ...) } worrms/R/wm_classification.R0000644000176200001440000000313313147640362015633 0ustar liggesusers#' Get classification for an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_children` it's #' required and must be `length(id) = 1`, for `wm_children_` it's #' optional and can be `length(id) >= 1` #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A tibble/data.frame. when using underscore method, outputs from #' each input are binded together, but can be split by `id` column #' @examples \dontrun{ #' wm_classification(id = 105706) #' wm_classification(id = 126436) #' #' wm_classification(254967) #' wm_classification(344089) #' #' # plural version, via id or name #' wm_classification_(id = c(254967, 344089)) #' wm_classification_(name = c('Platanista gangetica', 'Leucophaeus scoresbii')) #' } wm_classification <- function(id, ...) { assert(id, c("numeric", "integer")) res <- wm_GET(file.path(wm_base(), "AphiaClassificationByAphiaID", id), ...) done <- FALSE out <- list() it <- 0 while (!done) { it <- it + 1 ch <- res$child if (!is.null(ch)) { out[[it]] <- ch[!names(ch) %in% "child"] res <- list(child = ch$child) } else { done <- TRUE } } dat <- Filter(function(x) !is.null(x) && length(x) != 0, out) dat <- do.call("rbind.data.frame", dat) dat$rank <- as.character(dat$rank) dat$scientificname <- as.character(dat$scientificname) if (NROW(dat) == 0) dat <- NULL tibble::as_tibble(dat) } #' @export #' @rdname wm_classification wm_classification_ <- function(id = NULL, name = NULL, ...) { id <- id_name(id, name) run_bind(id, wm_classification, ...) } worrms/R/wm_common_id.R0000644000176200001440000000213613147640355014610 0ustar liggesusers#' Get vernacular names from an AphiaID #' #' @export #' @param id (numeric/integer) an AphiaID. For `wm_common_id` it's #' required and must be `length(id) = 1`, for `wm_common_id_` it's #' optional and can be `length(id) >= 1` #' @param name (character) one or more taxonomic names. optional #' @template curl #' @template plural #' @return A tibble/data.frame. when using underscore method, outputs from #' each input are binded together, but can be split by `id` column #' @examples \dontrun{ #' wm_common_id(id = 105706) #' wm_common_id(id = 156806) #' wm_common_id(id = 397065) #' #' wm_common_id_(id = c(105706, 156806, 397065)) #' nms <- c("Rhincodontidae", "Mesodesma deauratum", "Cryptomya californica") #' wm_common_id_(name = nms) #' } wm_common_id <- function(id, ...) { assert(id, c("numeric", "integer")) if (length(id) > 1) stop("'id' must be of length 1", call. = FALSE) wm_GET(file.path(wm_base(), "AphiaVernacularsByAphiaID", id), ...) } #' @export #' @rdname wm_common_id wm_common_id_ <- function(id = NULL, name = NULL, ...) { id <- id_name(id, name) run_bind(id, wm_common_id, ...) } worrms/R/wm_records_name.R0000644000176200001440000000251713147640302015300 0ustar liggesusers#' Get records by single name, optional fuzzy matching #' #' @export #' @param name (character) a taxonomic name, required. #' @param fuzzy (logical) fuzzy search. default: `TRUE` #' @param marine_only (logical) marine only or not. default: `TRUE` #' @param offset (integer) record to start at. default: 1 #' @template curl #' @note there is no underscore method like other functions in this package #' as there is already a plural version: [wm_records_names()] #' @return A tibble/data.frame #' @examples \dontrun{ #' wm_records_name(name = 'Platanista gangetica') #' wm_records_name(name = 'Platanista gangetica', fuzzy = FALSE) #' wm_records_name(name = 'Platanista gangetica', marine_only = FALSE) #' wm_records_name(name = 'Platanista', marine_only = FALSE) #' wm_records_name(name = 'Platanista', marine_only = FALSE, offset = 5) #' } wm_records_name <- function(name, fuzzy = TRUE, marine_only = TRUE, offset = 1, ...) { assert(name, "character") assert(fuzzy, "logical") assert(marine_only, "logical") assert(offset, c('numeric', 'integer')) if (length(name) > 1) stop("'name' must be of length 1", call. = FALSE) args <- cc(list( like = as_log(fuzzy), marine_only = as_log(marine_only), offset = offset )) wm_GET(file.path(wm_base(), "AphiaRecordsByName", name), query = args, ...) } worrms/R/wm_name2id.R0000644000176200001440000000126613147640335014164 0ustar liggesusers#' Get AphiaID from a taxonomic name #' #' @export #' @param name (character) a taxonomic name, required. For #' `wm_name2id` must be `length(id) = 1`, but for `wm_name2id_` #' can be `length(id) >= 1` #' @template curl #' @template plural #' @return An integer that is the AphiaID. When using underscore method, #' a list, named by the input names #' @examples \dontrun{ #' wm_name2id(name = "Rhincodon") #' wm_name2id_(name = c("Rhincodon", "Gadus morhua")) #' } wm_name2id <- function(name, ...) { assert(name, "character") wm_GET(file.path(wm_base(), "AphiaIDByName", name), ...) } #' @export #' @rdname wm_name2id wm_name2id_ <- function(name, ...) { run_c(name, wm_name2id, ...) } worrms/R/zzz.R0000644000176200001440000000361013147633205012770 0ustar liggesuserswm_GET <- function(url, query = list(), ...) { cli <- crul::HttpClient$new(url = url, opts = list(...)) temp <- cli$get(query = query) temp$raise_for_status() if (temp$status_code == 204) { stop(sprintf("(%s) %s", temp$status_code, temp$status_http()$message), call. = FALSE) } tmp <- jsonlite::fromJSON(temp$parse("UTF-8"), flatten = TRUE) if (inherits(tmp, "data.frame")) { tibble::as_data_frame(tmp) } else if (inherits(tmp, "list")) { if (all(sapply(tmp, class) == "data.frame")) { lapply(tmp, tibble::as_data_frame) } else { tmp } } else { tmp } } wm_base <- function() "http://www.marinespecies.org/rest" cc <- function(x) Filter(Negate(is.null), x) ccn <- function(x) { Filter(function(z) !is.null(z) && NROW(z) > 0, x) } `%||%` <- function(x, y) if (is.null(x) || length(x) == 0) y else x as_log <- function(x) { if (is.null(x)) { x } else { if (x) "true" else "false" } } assert <- function(x, y) { if (!is.null(x)) { if (!class(x) %in% y) { stop(deparse(substitute(x)), " must be of class ", paste0(y, collapse = ", "), call. = FALSE) } } } br <- function(x) { (x <- data.table::setDF( data.table::rbindlist(x, use.names = TRUE, fill = TRUE, idcol = "id"))) } run_c <- function(id, fun, ...) { ccn(stats::setNames(lapply(id, fun, ...), id)) } run_bind <- function(id, fun, ...) { tibble::as_tibble(br(ccn( stats::setNames(lapply(id, fun, ...), id) ))) } id_name <- function(id, name) { if (!xor(is.null(id), is.null(name))) stop("use only one of 'id' or 'name'") if (!is.null(name)) { unlist(lapply(name, safe_wm_name2id), FALSE) } else { id } } safe_wm_name2id <- function(x, ...) { res <- tryCatch(wm_name2id(x, ...), error = function(e) e) if (inherits(res, "error")) { warning(sprintf("%s: %s", x, res$message)) return(NULL) } else { return(res) } } worrms/vignettes/0000755000176200001440000000000013147642433013622 5ustar liggesusersworrms/vignettes/worrms_vignette.Rmd0000644000176200001440000002127413147636503017533 0ustar liggesusers Introduction to the worrms package ================================== `worrms` is an R client for the [World Register of Marine Species](http://www.marinespecies.org/). ## Install Stable version from CRAN ```r install.packages("worrms") ``` Development version from GitHub ```r install.packages("devtools") devtools::install_github("ropensci/worrms") ``` ```r library("worrms") ``` ## Get records WoRMS 'records' are taxa, not specimen occurrences or something else. by date ```r wm_records_date('2016-12-23T05:59:45+00:00') #> # A tibble: 50 x 25 #> AphiaID url #> * #> 1 894298 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894298 #> 2 894301 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894301 #> 3 894297 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894297 #> 4 894302 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894302 #> 5 894296 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894296 #> 6 894299 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894299 #> 7 894303 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894303 #> 8 915236 http://www.marinespecies.org/aphia.php?p=taxdetails&id=915236 #> 9 906769 http://www.marinespecies.org/aphia.php?p=taxdetails&id=906769 #> 10 909454 http://www.marinespecies.org/aphia.php?p=taxdetails&id=909454 #> # ... with 40 more rows, and 23 more variables: scientificname , #> # authority , status , unacceptreason , rank , #> # valid_AphiaID , valid_name , valid_authority , #> # kingdom , phylum , class , order , family , #> # genus , citation , lsid , isMarine , #> # isBrackish , isFreshwater , isTerrestrial , #> # isExtinct , match_type , modified ``` by a taxonomic name ```r wm_records_name(name = 'Platanista gangetica') #> # A tibble: 3 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> 2 383571 http://www.marinespecies.org/aphia.php?p=taxdetails&id=383571 #> 3 254969 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254969 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` by many names ```r wm_records_names(name = c('Platanista gangetica', 'Coryphaena')) #> [[1]] #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified #> #> [[2]] #> # A tibble: 2 x 25 #> AphiaID url #> * #> 1 125960 http://www.marinespecies.org/aphia.php?p=taxdetails&id=125960 #> 2 843430 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` by common name ```r wm_records_common(name = 'clam') #> # A tibble: 2 x 25 #> AphiaID url #> * #> 1 141919 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141919 #> 2 141936 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141936 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` using the TAXMATCH algorithm ```r wm_records_taxamatch(name = 'Platanista gangetica') #> [[1]] #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` ## APHIA ID <--> name ```r wm_name2id(name = "Rhincodon") #> [1] 105749 ``` ```r wm_id2name(id = 105706) #> [1] "Rhincodontidae" ``` ## Get AphiaID via an external ID ```r wm_external(id = 1080) #> [1] 85257 wm_external(id = 105706) #> [1] 159854 ``` ## Get vernacular names from an AphiaID ```r wm_common_id(id = 156806) #> # A tibble: 2 x 3 #> vernacular language_code language #> * #> 1 gilded wedgeclam eng English #> 2 Turton's wedge clam eng English ``` ## Children Get direct taxonomic children for an AphiaID ```r wm_classification(id = 105706) #> # A tibble: 11 x 3 #> AphiaID rank scientificname #> * #> 1 2 Kingdom Animalia #> 2 1821 Phylum Chordata #> 3 146419 Subphylum Vertebrata #> 4 1828 Superclass Gnathostomata #> 5 11676 Superclass Pisces #> 6 10193 Class Elasmobranchii #> 7 368407 Subclass Neoselachii #> 8 368408 Infraclass Selachii #> 9 368410 Superorder Galeomorphi #> 10 10208 Order Orectolobiformes #> 11 105706 Family Rhincodontidae ``` ## Classification Get classification for an AphiaID ```r wm_classification(id = 105706) #> # A tibble: 11 x 3 #> AphiaID rank scientificname #> * #> 1 2 Kingdom Animalia #> 2 1821 Phylum Chordata #> 3 146419 Subphylum Vertebrata #> 4 1828 Superclass Gnathostomata #> 5 11676 Superclass Pisces #> 6 10193 Class Elasmobranchii #> 7 368407 Subclass Neoselachii #> 8 368408 Infraclass Selachii #> 9 368410 Superorder Galeomorphi #> 10 10208 Order Orectolobiformes #> 11 105706 Family Rhincodontidae ``` ## Synonyms Get synonyms for an AphiaID ```r wm_synonyms(id = 105706) #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 148832 http://www.marinespecies.org/aphia.php?p=taxdetails&id=148832 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` worrms/README.md0000644000176200001440000001541013147642362013073 0ustar liggesusersworrms ====== [![Build Status](https://travis-ci.org/ropensci/worrms.svg?branch=master)](https://travis-ci.org/ropensci/worrms) [![codecov](https://codecov.io/gh/ropensci/worrms/branch/master/graph/badge.svg)](https://codecov.io/gh/ropensci/worrms) [![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/worrms)](https://github.com/metacran/cranlogs.app) [![cran version](http://www.r-pkg.org/badges/version/worrms)](https://cran.r-project.org/package=worrms) `worrms` is a R client for the World Register of Marine Species * [World Register of Marine Species (WoRMS)](http://www.marinespecies.org/) * [WoRMS REST API docs](http://www.marinespecies.org/rest/) ## Installation More stable CRAN version ```r install.packages("worrms") ``` Development version ```r devtools::install_github("ropensci/worrms") ``` ```r library("worrms") ``` ## get records by date ```r wm_records_date('2016-12-23T05:59:45+00:00') #> # A tibble: 50 x 25 #> AphiaID url #> * #> 1 894298 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894298 #> 2 894301 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894301 #> 3 894297 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894297 #> 4 894302 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894302 #> 5 894296 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894296 #> 6 894299 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894299 #> 7 894303 http://www.marinespecies.org/aphia.php?p=taxdetails&id=894303 #> 8 915236 http://www.marinespecies.org/aphia.php?p=taxdetails&id=915236 #> 9 897486 http://www.marinespecies.org/aphia.php?p=taxdetails&id=897486 #> 10 901957 http://www.marinespecies.org/aphia.php?p=taxdetails&id=901957 #> # ... with 40 more rows, and 23 more variables: scientificname , #> # authority , status , unacceptreason , rank , #> # valid_AphiaID , valid_name , valid_authority , #> # kingdom , phylum , class , order , family , #> # genus , citation , lsid , isMarine , #> # isBrackish , isFreshwater , isTerrestrial , #> # isExtinct , match_type , modified ``` by a taxonomic name ```r wm_records_name(name = 'Platanista gangetica') #> # A tibble: 3 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> 2 383571 http://www.marinespecies.org/aphia.php?p=taxdetails&id=383571 #> 3 254969 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254969 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` by many names ```r wm_records_names(name = c('Platanista gangetica', 'Coryphaena')) #> [[1]] #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified #> #> [[2]] #> # A tibble: 2 x 25 #> AphiaID url #> * #> 1 125960 http://www.marinespecies.org/aphia.php?p=taxdetails&id=125960 #> 2 843430 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` by common name ```r wm_records_common(name = 'clam') #> # A tibble: 2 x 25 #> AphiaID url #> * #> 1 141919 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141919 #> 2 141936 http://www.marinespecies.org/aphia.php?p=taxdetails&id=141936 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` using the TAXMATCH algorithm ```r wm_records_taxamatch(name = 'Platanista gangetica') #> [[1]] #> # A tibble: 1 x 25 #> AphiaID url #> * #> 1 254967 http://www.marinespecies.org/aphia.php?p=taxdetails&id=254967 #> # ... with 23 more variables: scientificname , authority , #> # status , unacceptreason , rank , valid_AphiaID , #> # valid_name , valid_authority , kingdom , phylum , #> # class , order , family , genus , citation , #> # lsid , isMarine , isBrackish , isFreshwater , #> # isTerrestrial , isExtinct , match_type , modified ``` ## Meta * Please [report any issues or bugs](https://github.com/ropensci/worrms/issues). * License: MIT * Get citation information for `worrms` in R doing `citation(package = 'worrms')` * Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. worrms/MD50000644000176200001440000000671613147645027012136 0ustar liggesusersec9d9626166c258495a36beb0abe034f *DESCRIPTION c5af52351472a750055a760a8924ce71 *LICENSE b6b7456caa197a93e535e34de82a4af2 *NAMESPACE 90f223b65cff5924fec01b1d95dd9882 *NEWS.md 59c949d3b9564ee6ce9558396c828982 *R/wm_children.R 2e9a31a9642417b5530ac30c579e56e9 *R/wm_classification.R f39821f4ff0424b276b53566912678d5 *R/wm_common_id.R 7700a9da2fcdd3bc76060c3de3eaa67a *R/wm_distribution.R 00c13effca08cdefbc1c03d337710b5f *R/wm_externalid.R d10cc2f4a6f847822ceb63da179796ed *R/wm_id2name.R cee3c01e1966c316d1943efd44cf105b *R/wm_name2id.R 254147524406295ac0960c6332a06e72 *R/wm_record.R a5c9b9f861af6b28fdb65ea17ef5aa44 *R/wm_record_by_external.R e15977879a9340e502c39cd5c08a0048 *R/wm_records_common.R b909237e8e085479a6c9b568f6a724b2 *R/wm_records_date.R 919efdb7a7d07158900bafc6784ac5af *R/wm_records_name.R 1feae9804c69e4b4d1f89be1270113cb *R/wm_records_names.R c033490ecb141f04e3298aff6ad2732f *R/wm_records_taxamatch.R 0708d9f54fd1f512b75384a3d2e89823 *R/wm_sources.R 09e3585255f51ced9dc37946c9c8a78b *R/wm_synonyms.R 83ed3219fe18d32688329a3f08525ae3 *R/worrms-package.R 8fdecd9093b8b17e342b06c829d9e62d *R/zzz.R c7eb502fe23d53a9ecdb416ba0274069 *README.md 23c4dce42c6f7cf19afe133df05daacc *build/vignette.rds 9b16404f84e0fb5001d67d8227027cfb *inst/doc/worrms_vignette.Rmd ac729492fda9b5d15b25b3647b9ac80a *inst/doc/worrms_vignette.html e3bfcd5817bf2999e3369dddc391cebe *man/wm_children.Rd d6ebf6dcbbcb7cdc96158d10cded9007 *man/wm_classification.Rd 5e2781052138ac986a4b066f636e86ca *man/wm_common_id.Rd 0e63182190043db3b4cf10f81a2a63e8 *man/wm_distribution.Rd c1d9dda918754a5aeca36bfbfaf7613e *man/wm_external.Rd f0db9af6b321298e883e1f029b3e6965 *man/wm_id2name.Rd 129bf8c37cc547013a92438744eb2a67 *man/wm_name2id.Rd c6077db2becdfec44df2128f52ed72eb *man/wm_record.Rd 14c1fc7664ad2d63d072bf794fc461a5 *man/wm_record_by_external.Rd 473c7c92abc5fb159291ff0cb5b27972 *man/wm_records_common.Rd ef2697c9e55812e6d2569c1ac871052e *man/wm_records_date.Rd cfab8f04044b53830295875f101a3e93 *man/wm_records_name.Rd b976bb9b7284420778cff4577e0e7468 *man/wm_records_names.Rd e7412f06f2199f39bdfe628264faa674 *man/wm_records_taxamatch.Rd ec7b7c16366e2188c27bebbc63a0f743 *man/wm_sources.Rd 7cdbe8e989b13c30eed766be8bc8a49d *man/wm_synonyms.Rd e35439a3e8932454af1c1c560096397f *man/worrms-package.Rd 8c7030aa348e0a2b9cb58ff224192b05 *tests/test-all.R 4d7285c17688a8af9404017541094773 *tests/testthat/test-wm_children.R 35d7caffac2ec08bb14176f824a01391 *tests/testthat/test-wm_classification.R a1fa3dbe76b7303772750881222b5e7c *tests/testthat/test-wm_common_id.R 60b0a3e07cf0d6f40cf744b374fd6705 *tests/testthat/test-wm_distribution.R f95185edd01923af137f52429ee8e1c8 *tests/testthat/test-wm_external.R fe5c2359d542ddb8528e0bbf3dc68c8d *tests/testthat/test-wm_id2name.R 4706f7ee48270ba0998cdfb06f51b072 *tests/testthat/test-wm_name2id.R 09295c57cd8404d7fa5276d933fdf58c *tests/testthat/test-wm_record.R 0773b37369da885d40a25530c80ab315 *tests/testthat/test-wm_record_by_external.R e2de4e70b45b7d67317c667cd2eff358 *tests/testthat/test-wm_records_common.R 940457feed462710141f16834ed768fe *tests/testthat/test-wm_records_date.R 77d27c7b71d6c6e37ddc3214cf6472a8 *tests/testthat/test-wm_records_name.R a4b3f48df5bdeaa7de22e49b57660787 *tests/testthat/test-wm_records_names.R 86f804037d073d3dda9d28cede013496 *tests/testthat/test-wm_records_taxamatch.R 0fa12fa5cabf50ff6e937871e1a906cf *tests/testthat/test-wm_sources.R 9e4ff284596e70c530186cafcd1eacfa *tests/testthat/test-wm_synonyms.R 9b16404f84e0fb5001d67d8227027cfb *vignettes/worrms_vignette.Rmd worrms/build/0000755000176200001440000000000013147642433012711 5ustar liggesusersworrms/build/vignette.rds0000644000176200001440000000034013147642433015245 0ustar liggesusersmO 0 .^6W"oRí]t旫:h!ip\KN@O1+). Includes functions for each of the API methods, including searching for names by name, date and common names, searching using external identifiers, fetching synonyms, as well as fetching taxonomic children and taxonomic classification. Version: 0.2.0 Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"), email = "myrmecocystus@gmail.com")) License: MIT + file LICENSE URL: https://github.com/ropensci/worrms BugReports: https://github.com/ropensci/worrms/issues LazyData: true VignetteBuilder: knitr Imports: crul (>= 0.3.6), tibble (>= 1.2), jsonlite (>= 1.1), data.table Suggests: roxygen2 (>= 6.0.1), knitr, testthat RoxygenNote: 6.0.1 NeedsCompilation: no Packaged: 2017-08-24 21:29:00 UTC; sacmac Author: Scott Chamberlain [aut, cre] Maintainer: Scott Chamberlain Repository: CRAN Date/Publication: 2017-08-24 21:50:15 UTC worrms/man/0000755000176200001440000000000013147642434012366 5ustar liggesusersworrms/man/wm_external.Rd0000644000176200001440000000343213147640373015204 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_externalid.R \name{wm_external} \alias{wm_external} \alias{wm_external_} \title{Get an external ID via an AphiaID} \usage{ wm_external(id, type = "tsn", ...) wm_external_(id = NULL, name = NULL, type = "tsn", ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_external} it's required and must be \code{length(id) = 1}, for \code{wm_external_} it's optional and can be \code{length(id) >= 1}} \item{type}{(character) the type of external id. one of: tsn, bold, dyntaxa, eol, fishbase, iucn, lsid, ncbi, gisd. default: tsn} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ An integer that is the ID. When using underscore method, a list, named by the input IDs } \description{ Get an external ID via an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ # by default, get a TSN (an ITIS code) wm_external(id = 1080) ## get many wm_external_(id = c(1080, 126436)) # BOLD code wm_external(id = 278468, type = "bold") # NCBI code wm_external(id = 278468, type = "ncbi") # fishbase code wm_external(id = 278468, type = "fishbase") # curl options library(crul) wm_external(id = 105706, verbose = TRUE) } } worrms/man/wm_id2name.Rd0000644000176200001440000000237313147640373014704 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_id2name.R \name{wm_id2name} \alias{wm_id2name} \alias{wm_id2name_} \title{Get taxonomic name for an AphiaID} \usage{ wm_id2name(id, ...) wm_id2name_(id, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID, required. For \code{wm_id2name} must be \code{length(id) = 1}, but for \code{wm_id2name_} can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} } \value{ An character string that is the taxnomic name. When using underscore method, a list, named by the input IDs } \description{ Get taxonomic name for an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_id2name(id = 105706) wm_id2name_(id = c(105706, 126436)) } } worrms/man/wm_records_names.Rd0000644000176200001440000000201413147640373016201 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_records_names.R \name{wm_records_names} \alias{wm_records_names} \title{Get records for onen or more taxonomic name(s)} \usage{ wm_records_names(name, fuzzy = FALSE, marine_only = TRUE, ...) } \arguments{ \item{name}{(character) start date. required.} \item{fuzzy}{(logical) fuzzy search. default: \code{FALSE}} \item{marine_only}{(logical) marine only or not. default: \code{TRUE}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} } \value{ A list of tibble's/data.frame's, one for each of the input names } \description{ Get records for onen or more taxonomic name(s) } \note{ there is no underscore method like other functions in this package as this is the plural version for \code{\link[=wm_records_name]{wm_records_name()}} } \examples{ \dontrun{ wm_records_names(name = 'Platanista gangetica') wm_records_names(name = 'Platanista gangetica', fuzzy = TRUE) wm_records_names(name = c('Platanista gangetica', 'Coryphaena')) } } worrms/man/worrms-package.Rd0000644000176200001440000000134413102724155015571 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/worrms-package.R \docType{package} \name{worrms-package} \alias{worrms-package} \alias{worrms} \title{World Register of Marine Species Client} \description{ World Register of Marine Species Client } \section{Fail behavior}{ The WoRMS REST API doesn't have sophisticated error messaging, so most errors will result in a \code{(204) - No Content} or in \code{(400) - Bad Request} Because WoRMS doesn't do comprehensive error reporting, we do a fair amount of checking user inputs to help prevent errors that will be meaningless to the user. Let us know if we can improve on this. } \author{ Scott Chamberlain \email{myrmecocystus@gmail.com} } \keyword{package} worrms/man/wm_children.Rd0000644000176200001440000000340313147640373015150 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_children.R \name{wm_children} \alias{wm_children} \alias{wm_children_} \title{Get children for an AphiaID} \usage{ wm_children(id, marine_only = TRUE, offset = 1, ...) wm_children_(id = NULL, name = NULL, marine_only = TRUE, offset = 1, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_children} it's required and must be \code{length(id) = 1}, for \code{wm_children_} it's optional and can be \code{length(id) >= 1}} \item{marine_only}{(logical) marine only or not. default: \code{TRUE}} \item{offset}{(integer) record to start at. default: 1} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A tibble/data.frame. when using underscore method, outputs from each input are binded together, but can be split by \code{id} column } \description{ Get children for an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_children(id = 105706) wm_children(id = 105706, FALSE) wm_children(id = 105706, offset = 5) wm_children(254966) wm_children(343613) # plural version, via id or name wm_children_(id = c(254966, 343613)) wm_children_(name = c('Platanista', 'Leucophaeus')) } } worrms/man/wm_sources.Rd0000644000176200001440000000270113147640373015043 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_sources.R \name{wm_sources} \alias{wm_sources} \alias{wm_sources_} \title{Get sources for an AphiaID} \usage{ wm_sources(id, ...) wm_sources_(id = NULL, name = NULL, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_sources} it's required and must be \code{length(id) = 1}, for \code{wm_sources_} it's optional and can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A tibble/data.frame. when using underscore method, outputs from each input are binded together, but can be split by \code{id} column } \description{ Get sources for an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_sources(id = 105706) wm_sources_(id = 105706) wm_sources_(id = c(105706, 126436)) wm_sources_(name = c("Rhincodontidae", "Gadus morhua")) } } worrms/man/wm_distribution.Rd0000644000176200001440000000271413147640373016103 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_distribution.R \name{wm_distribution} \alias{wm_distribution} \alias{wm_distribution_} \title{Get distribution data by AphiaID} \usage{ wm_distribution(id, ...) wm_distribution_(id = NULL, name = NULL, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_distribution} it's required and must be \code{length(id) = 1}, for \code{wm_distribution_} it's optional and can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A tibble/data.frame. when using underscore method, outputs from each input are binded together, but can be split by \code{id} column } \description{ Get distribution data by AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_distribution(id = 156806) wm_distribution(id = 126436) wm_distribution_(id = c(156806, 126436)) } } worrms/man/wm_record.Rd0000644000176200001440000000256413147640373014645 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_record.R \name{wm_record} \alias{wm_record} \alias{wm_record_} \title{Get complete AphiaRecord for an AphiaID} \usage{ wm_record(id, ...) wm_record_(id = NULL, name = NULL, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_record} it's required and must be \code{length(id) = 1}, for \code{wm_record_} it's optional and can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A named list. When using underscore method, each output is named by the input ID, and can be separated by the list names } \description{ Get complete AphiaRecord for an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_record(id = 105706) wm_record_(id = c(105706, 126436)) } } worrms/man/wm_records_name.Rd0000644000176200001440000000226613147640373016027 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_records_name.R \name{wm_records_name} \alias{wm_records_name} \title{Get records by single name, optional fuzzy matching} \usage{ wm_records_name(name, fuzzy = TRUE, marine_only = TRUE, offset = 1, ...) } \arguments{ \item{name}{(character) a taxonomic name, required.} \item{fuzzy}{(logical) fuzzy search. default: \code{TRUE}} \item{marine_only}{(logical) marine only or not. default: \code{TRUE}} \item{offset}{(integer) record to start at. default: 1} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} } \value{ A tibble/data.frame } \description{ Get records by single name, optional fuzzy matching } \note{ there is no underscore method like other functions in this package as there is already a plural version: \code{\link[=wm_records_names]{wm_records_names()}} } \examples{ \dontrun{ wm_records_name(name = 'Platanista gangetica') wm_records_name(name = 'Platanista gangetica', fuzzy = FALSE) wm_records_name(name = 'Platanista gangetica', marine_only = FALSE) wm_records_name(name = 'Platanista', marine_only = FALSE) wm_records_name(name = 'Platanista', marine_only = FALSE, offset = 5) } } worrms/man/wm_records_taxamatch.Rd0000644000176200001440000000171413147636006017054 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_records_taxamatch.R \name{wm_records_taxamatch} \alias{wm_records_taxamatch} \title{Get records for onen or more taxonomic name(s) using the TAXAMATCH fuzzy matching algorithm} \usage{ wm_records_taxamatch(name, marine_only = TRUE, ...) } \arguments{ \item{name}{(character) taxon name. required.} \item{marine_only}{(logical) marine only or not. default: \code{TRUE}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} } \value{ A list of tibble's/data.frame's, one for each of the input names } \description{ Get records for onen or more taxonomic name(s) using the TAXAMATCH fuzzy matching algorithm } \note{ there is no underscore method like other functions in this package as this function already accepts many names } \examples{ \dontrun{ wm_records_taxamatch(name = 'Platanista gangetica') wm_records_taxamatch(name = c('Platanista gangetica', 'Coryphaena')) } } worrms/man/wm_name2id.Rd0000644000176200001440000000241213147640373014676 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_name2id.R \name{wm_name2id} \alias{wm_name2id} \alias{wm_name2id_} \title{Get AphiaID from a taxonomic name} \usage{ wm_name2id(name, ...) wm_name2id_(name, ...) } \arguments{ \item{name}{(character) a taxonomic name, required. For \code{wm_name2id} must be \code{length(id) = 1}, but for \code{wm_name2id_} can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} } \value{ An integer that is the AphiaID. When using underscore method, a list, named by the input names } \description{ Get AphiaID from a taxonomic name } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_name2id(name = "Rhincodon") wm_name2id_(name = c("Rhincodon", "Gadus morhua")) } } worrms/man/wm_common_id.Rd0000644000176200001440000000307213147640373015326 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_common_id.R \name{wm_common_id} \alias{wm_common_id} \alias{wm_common_id_} \title{Get vernacular names from an AphiaID} \usage{ wm_common_id(id, ...) wm_common_id_(id = NULL, name = NULL, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_common_id} it's required and must be \code{length(id) = 1}, for \code{wm_common_id_} it's optional and can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A tibble/data.frame. when using underscore method, outputs from each input are binded together, but can be split by \code{id} column } \description{ Get vernacular names from an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_common_id(id = 105706) wm_common_id(id = 156806) wm_common_id(id = 397065) wm_common_id_(id = c(105706, 156806, 397065)) nms <- c("Rhincodontidae", "Mesodesma deauratum", "Cryptomya californica") wm_common_id_(name = nms) } } worrms/man/wm_record_by_external.Rd0000644000176200001440000000322113147640373017230 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_record_by_external.R \name{wm_record_by_external} \alias{wm_record_by_external} \alias{wm_record_by_external_} \title{Get record by external ID} \usage{ wm_record_by_external(id, type = "tsn", ...) wm_record_by_external_(id = NULL, name = NULL, type = "tsn", ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_record_by_external} it's required and must be \code{length(id) = 1}, for \code{wm_record_by_external_} it's optional and can be \code{length(id) >= 1}} \item{type}{(character) the type of external id. one of: tsn, bold, dyntaxa, eol, fishbase, iucn, lsid, ncbi, gisd. default: tsn} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A named list. When using underscore method, each output is named by the input ID, and can be separated by the list names } \description{ Get record by external ID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_record_by_external(id = 85257) wm_record_by_external(id = 159854) wm_record_by_external_(id = c(85257, 159854)) } } worrms/man/wm_records_date.Rd0000644000176200001440000000137113147640373016020 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_records_date.R \name{wm_records_date} \alias{wm_records_date} \title{Get records by date} \usage{ wm_records_date(start_date, end_date = NULL, marine_only = TRUE, offset = 1, ...) } \arguments{ \item{start_date}{(character) start date. required.} \item{end_date}{(character) end date. optional} \item{marine_only}{(logical) marine only or not. default: \code{TRUE}} \item{offset}{(integer) record to start at. default: 1} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} } \value{ A tibble/data.frame } \description{ Get records by date } \examples{ \dontrun{ a_date <- format(Sys.Date() - 1, "\%Y-\%m-\%dT\%H:\%M:\%S+00:00") wm_records_date(a_date) } } worrms/man/wm_synonyms.Rd0000644000176200001440000000262613147640373015265 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_synonyms.R \name{wm_synonyms} \alias{wm_synonyms} \alias{wm_synonyms_} \title{Get synonyms for an AphiaID} \usage{ wm_synonyms(id, ...) wm_synonyms_(id = NULL, name = NULL, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_synonyms} it's required and must be \code{length(id) = 1}, for \code{wm_synonyms_} it's optional and can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A tibble/data.frame. when using underscore method, outputs from each input are binded together, but can be split by \code{id} column } \description{ Get synonyms for an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_synonyms(id = 105706) wm_synonyms_(id = 105706) wm_synonyms_(id = c(105706, 126436)) } } worrms/man/wm_classification.Rd0000644000176200001440000000317413147640373016360 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_classification.R \name{wm_classification} \alias{wm_classification} \alias{wm_classification_} \title{Get classification for an AphiaID} \usage{ wm_classification(id, ...) wm_classification_(id = NULL, name = NULL, ...) } \arguments{ \item{id}{(numeric/integer) an AphiaID. For \code{wm_children} it's required and must be \code{length(id) = 1}, for \code{wm_children_} it's optional and can be \code{length(id) >= 1}} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} \item{name}{(character) one or more taxonomic names. optional} } \value{ A tibble/data.frame. when using underscore method, outputs from each input are binded together, but can be split by \code{id} column } \description{ Get classification for an AphiaID } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_classification(id = 105706) wm_classification(id = 126436) wm_classification(254967) wm_classification(344089) # plural version, via id or name wm_classification_(id = c(254967, 344089)) wm_classification_(name = c('Platanista gangetica', 'Leucophaeus scoresbii')) } } worrms/man/wm_records_common.Rd0000644000176200001440000000332313147640373016372 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wm_records_common.R \name{wm_records_common} \alias{wm_records_common} \alias{wm_records_common_} \title{Get records by vernacular name, optional fuzzy matching} \usage{ wm_records_common(name, fuzzy = FALSE, offset = 1, ...) wm_records_common_(name, fuzzy = FALSE, offset = 1, ...) } \arguments{ \item{name}{(character) a species common name. required. For \code{wm_records_common} must be \code{length(id) = 1}; for \code{wm_records_common_} can be \code{length(id) >= 1}} \item{fuzzy}{(logical) fuzzy search. default: \code{FALSE}} \item{offset}{(integer) record to start at. default: 1} \item{...}{named curl options. see \code{\link[curl]{curl_options}}} } \value{ A tibble/data.frame. when using underscore method, outputs from each input are binded together, but can be split by \code{id} column } \description{ Get records by vernacular name, optional fuzzy matching } \section{Singular vs. plural}{ Of the two sister functions, the one without the underscore is the original function that wraps the relavant WoRMS API method - and only accepts one thing (i.e., name or AphiaID) per request. The sister function with the underscore at the end is the plural version, accepting more than one input. Internally this function loops over the non-underscore method, and labels output (whether it's a list or data.frame rows) with the input names or IDs so that you can easily parse output by your inputs. } \examples{ \dontrun{ wm_records_common(name = 'dolphin') wm_records_common(name = 'clam') wm_records_common_(name = c('dolphin', 'clam')) wm_records_common(name = 'dolphin', fuzzy = TRUE) wm_records_common(name = 'clam', fuzzy = TRUE, offset = 5) } } worrms/LICENSE0000644000176200001440000000005713033053405012606 0ustar liggesusersYEAR: 2017 COPYRIGHT HOLDER: Scott Chamberlain