<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{traits Intro}
%\VignetteEncoding{UTF-8}
-->

```{r echo=FALSE}
knitr::opts_chunk$set(
  comment = "#>",
  collapse = TRUE,
  warning = FALSE,
  message = FALSE,
  cache.path = "vigncache/"
)
```

`traits` introduction
=====================

```{r}
library("traits")
```

## BetyDB

Get trait data for Willow (_Salix_ spp.)

```{r}
(salix <- betydb_search("Salix Vcmax"))
# equivalent:
# (out <- betydb_search("willow"))
```

Summarise data from the output `data.frame`

```{r}
library("dplyr")
salix %>%
  group_by(scientificname, trait) %>%
  mutate(.mean = as.numeric(mean)) %>%
  summarise(mean = round(mean(.mean, na.rm = TRUE), 2),
            min = round(min(.mean, na.rm = TRUE), 2),
            max = round(max(.mean, na.rm = TRUE), 2),
            n = length(n))

```

## NCBI sequence data

Get sequences by id

```{r}
ncbi_byid(ids = "360040093")
```

Get sequences searching by taxonomic name

```{r}
out <- ncbi_searcher(taxa = "Umbra limi", seqrange = "1:2000")
head(out)
```

## EOL's traitbank trait data

Searching for _Balaenoptera musculus_ (blue whale), page id `328574`

```{r}
res <- traitbank(328574)
res$graph %>%
  select(`dwc:measurementtype`) %>%
  filter(!is.na(`dwc:measurementtype`))
```

## Coral

Get the species list and their ids

```{r}
coral_species()
```

Get data by taxon

```{r}
coral_taxa(80)
```

Get data by trait

```{r}
coral_traits(105)
```

## Birdlife International

Habitat data

```{r}
birdlife_habitat(22721692)
```

Threats data

```{r}
birdlife_threats(22721692)
```
