R: Get the UK National Biodiversity Network ID from taxonomic...

get_nbnid {taxize} | R Documentation

## Get the UK National Biodiversity Network ID from taxonomic names.

### Description

Get the UK National Biodiversity Network ID from taxonomic names.

### Usage

    get_nbnid(name, ask = TRUE, verbose = TRUE, rec_only = FALSE,
      rank = NULL, rows = NA, ...)

    as.nbnid(x, check = TRUE)

    ## S3 method for class 'nbnid'
    as.nbnid(x, check = TRUE)

    ## S3 method for class 'character'
    as.nbnid(x, check = TRUE)

    ## S3 method for class 'list'
    as.nbnid(x, check = TRUE)

    ## S3 method for class 'data.frame'
    as.nbnid(x, check = TRUE)

    ## S3 method for class 'nbnid'
    as.data.frame(x, ...)

    get_nbnid_(name, verbose = TRUE, rec_only = FALSE, rank = NULL,
      rows = NA, ...)

### Arguments

`name` | character; scientific name.
`ask` | logical; should get_nbnid be run in interactive mode? If TRUE and more than one ID is found for the species, the user is asked for input. If FALSE NA is returned for multiple matches.
`verbose` | logical; If TRUE the actual taxon queried is printed on the console.
`rec_only` | (logical) If `TRUE` ids of recommended names are returned (i.e. synonyms are removed). Defaults to `FALSE`. Remember, the id of a synonym is a taxa with 'recommended' name status.
`rank` | (character) If given, we attempt to limit the results to those taxa with the matching rank.
`rows` | numeric; Any number from 1 to infinity. If the default NA, all rows are considered. Note that this function still only gives back a nbnid class object with one to many identifiers. See `get_nbnid_` to get back all, or a subset, of the raw data that you are presented during the ask process.
`...` | Further args passed on to `nbn_search`
`x` | Input to `as.nbnid`
`check` | logical; Check if ID matches any existing on the DB, only used in `as.nbnid`

### Value

A vector of taxonomic identifiers as an S3 class. If a taxon is not found an `NA` is given. If more than one identifier is found the function asks for user input if `ask = TRUE`, otherwise returns `NA`. If `ask=FALSE` and `rows` does not equal `NA`, then a data.frame is given back, but not of the uid class, which you can't pass on to other functions as you normally can.

See `get_id_details` for further details including attributes and exceptions

an object of class nbnid, a light wrapper around a character string that is the taxonomic ID - includes attributes with relavant metadata

### Author(s)

Scott Chamberlain, myrmecocystus@gmail.com

### References

<https://api.nbnatlas.org/>

### See Also

`classification`

Other taxonomic-ids: `get_boldid`, `get_colid`, `get_eolid`, `get_gbifid`, `get_ids`, `get_iucn`, `get_natservid`, `get_tolid`, `get_tpsid`, `get_tsn`, `get_uid`, `get_wiki`, `get_wormsid`

Other nbn: `nbn_classification`, `nbn_search`, `nbn_synonyms`

### Examples

    ## Not run:
    get_nbnid(name='Poa annua')
    get_nbnid(name='Poa annua', rec_only=TRUE)
    get_nbnid(name='Poa annua', rank='Species')
    get_nbnid(name='Poa annua', rec_only=TRUE, rank='Species')
    get_nbnid(name='Pinus contorta')

    # The NBN service handles common names too
    get_nbnid(name='red-winged blackbird')

    # specify rows to limit choices available
    get_nbnid('Poa annua')
    get_nbnid('Poa annua', rows=1)
    get_nbnid('Poa annua', rows=25)
    get_nbnid('Poa annua', rows=1:2)

    # When not found
    get_nbnid(name="uaudnadndj")
    get_nbnid(c("Zootoca vivipara", "uaudnadndj"))
    get_nbnid(c("Zootoca vivipara","Chironomus riparius", "uaudnadndj"))

    # Convert an nbnid without class information to a nbnid class
    as.nbnid(get_nbnid("Zootoca vivipara")) # already a nbnid, returns the same
    as.nbnid(get_nbnid(c("Zootoca vivipara","Pinus contorta"))) # same
    as.nbnid('NHMSYS0001706186') # character
    # character vector, length > 1
    as.nbnid(c("NHMSYS0001706186","NHMSYS0000494848","NBNSYS0000010867"))
    # list
    as.nbnid(list("NHMSYS0001706186","NHMSYS0000494848","NBNSYS0000010867"))
    ## dont check, much faster
    as.nbnid('NHMSYS0001706186', check=FALSE)
    as.nbnid(list("NHMSYS0001706186","NHMSYS0000494848","NBNSYS0000010867"),
      check=FALSE)

    (out <- as.nbnid(c("NHMSYS0001706186","NHMSYS0000494848",
      "NBNSYS0000010867")))
    data.frame(out)
    as.nbnid( data.frame(out) )

    # Get all data back
    get_nbnid_("Zootoca vivipara")
    get_nbnid_("Poa annua", rows=2)
    get_nbnid_("Poa annua", rows=1:2)
    get_nbnid_(c("asdfadfasd","Pinus contorta"), rows=1:5)

    # use curl options
    library("httr")
    get_nbnid("Quercus douglasii", config=verbose())
    bb <- get_nbnid("Quercus douglasii", config=progress())

    ## End(Not run)

[Package taxize version 0.9.0 Index]