---
title: Additional rbison functionality
author: Scott Chamberlain
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
    %\VignetteIndexEntry{Additional rbison functionality}
    %\VignetteEngine{knitr::rmarkdown}
    %\VignetteEncoding{UTF-8}
---

```{r echo=FALSE}
NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true")
knitr::opts_chunk$set(
  comment = "#>",
  collapse = TRUE,
  warning = FALSE,
  message = FALSE,
  purl = NOT_CRAN,
  eval = NOT_CRAN
)
```

The function `bison()` is sort of the main interface to searching for data in `rbison`, covered in the vignette _rbison introduction_. However, there are many other functions.


## Load rbison

```{r load}
library('rbison')
```

## Data provider statistics

BISON exposes an API supporting access to Data Provider and Resource based data access statistics.

```{r}
out <- bison_stats(what='wms')
out$Arctos
```

```{r}
out$Harvard_University_Herbaria
```

```{r}
out$ZooKeys
```

## Data provider information

```{r}
head(bison_providers(provider_no=131))
```

```{r}
out <- bison_providers(details=TRUE)
out$National_Herbarium_of_New_South_Wales
```

## The Solr taxonomic name endpoint

Search for and collect taxonomic name data from the USGS Bison API using solr.

```{r}
bison_tax(query="*bear")
```

Exact argument, here nothing found with latter call as `*bear` doesn't exist, which makes sense

```{r}
bison_tax(query="*bear", exact=FALSE)
```

```{r}
bison_tax(query="*bear", exact=TRUE)
```

Using solr arguments (not all Solr arguments work). Return a certain number of rows

```{r}
bison_tax(query="*bear", method="vernacularName", rows=3)
```

Return certain fields

```{r}
bison_tax(query="*bear", method="vernacularName", fl='vernacularName')
```

## The solr occurrence data endpoint

Search for and collect occurrence data from the USGS Bison API using their solr endpoint.

```{r}
bison_solr(scientificName='Ursus americanus', computedStateFips='02',
 fl="scientificName", rows=3)
```

```{r}
bison_solr(scientificName='Ursus americanus', computedStateFips='02',
 rows=3, fl="scientificName,decimalLongitude,decimalLatitude")
```

```{r}
bison_solr(TSNs = 174670, rows=2)$points[,1:6]
```

```{r}
bison_solr(kingdom = "Plantae", rows=2)$points[,1:6]
```

Using additional solr fields - Faceting

```{r}
bison_solr(scientificName='Helianthus annuus', rows=0, facet='true',
 facet.field='computedStateFips')
```

Highlighting

```{r}
bison_solr(scientificName='Helianthus annuus', rows=1, hl='true',
 hl.fl='scientificName')
```
