-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05-rvertnet.Rmd
71 lines (48 loc) · 1.39 KB
/
05-rvertnet.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
```{r echo=FALSE}
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE,
message = FALSE
)
```
# rvertnet {#rvertnet}
## What is rvertnet? {#what-rvertnet}
[rvertnet][] is an R package for interacting with [VertNet.org](http://vertnet.org/).
VertNet.org API docs: <https://github.com/VertNet/webapp/wiki/The-API-search-function>
## Basic example {#rvertnet-basic-example}
Load `rvertnet`
```{r}
library(rvertnet)
```
Search for _Aves_ in the state of _California_, limit to 10 records
```{r messages=FALSE}
res <- searchbyterm(class = "Aves", state = "California", lim = 10)
```
metadata
```{r collapse = TRUE}
res$meta
```
data. A `tibble` is given back:
```{r collapse = TRUE}
res$data
```
Search for _Mustela nigripes_ in the states of _Wyoming_ or _South Dakota_,
limit to 20 records
```{r collapse = TRUE}
res <- searchbyterm(specificepithet = "nigripes",
state = "(wyoming OR south dakota)", limit = 20)
res$data
```
### downstream data manipulation
You can pass the data object directly on to `dplyr` functions. Here, we get a
table of record counts by species in descending order.
```{r collapse = TRUE, cache = TRUE}
library("dplyr")
out <- searchbyterm(genus = "Ochotona", limit = 800)
out$data %>%
group_by(scientificname) %>%
summarise(count = length(scientificname)) %>%
arrange(desc(count))
```
[rvertnet]: https://github.com/ropensci/rvertnet