-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.qmd
160 lines (117 loc) · 2.83 KB
/
index.qmd
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
title: "`r paste('World', params$mammals_family, 'analysis')`"
author: "Jane Doe"
date: "`r format(Sys.time(), '%Y/%m/%d')`"
format:
html:
self_contained: true
fig_caption: yes
# theme: united
toc: true
toc_float:
collapsed: true
params:
mammals_family: "Ursidae"
execute:
echo: true
eval: true
message: false
fig-width: 7
fig-height: 7
knitr:
opts_chunk:
collapse: true
out-width: "100%"
dpi: 300
---
# Set up project
```{r}
#| label: 'setup'
#| message: false
## Load project ----
devtools::load_all()
```
# Data acquisition
```{r}
#| label: 'download-data'
#| eval: false
## Download data ----
dl_wildfinder_data()
```
# Data importation
## Mammals species list
```{r}
#| label: 'read-data-1'
## Import species list ----
sp_list <- read_sp_list(here::here("data", "wildfinder",
"wildfinder-mammals_list.csv"))
```
```{r}
#| label: 'print-data-1'
#| echo: false
knitr::kable(head(sp_list), caption = "Content of the wildfinder-mammals_list file")
```
## Ecoregions list
```{r}
#| label: 'read-data-2'
## Import ecoregions list ----
eco_list <- read_eco_list(here::here("data", "wildfinder",
"wildfinder-ecoregions_list.csv"))
```
```{r}
#| label: 'print-data-2'
#| echo: false
knitr::kable(head(eco_list), caption = "Content of the wildfinder-ecoregions_list file")
```
## Merging table
```{r}
#| label: 'read-data-3'
## Import merging table ----
sp_eco <- read_sp_eco(here::here("data", "wildfinder",
"wildfinder-ecoregions_species.csv"))
```
```{r}
#| label: 'print-data-3'
#| echo: false
knitr::kable(head(sp_eco), caption = "Content of the wildfinder-ecoregions_species file")
```
# Species selection
```{r}
#| label: 'select-species'
## Select species ----
sp_list <- select_species(sp_list, family = params$"mammals_family")
```
```{r}
#| label: 'print-data-4'
#| echo: false
knitr::kable(sp_list, caption = paste("List of World", params$"mammals_family", "species"))
```
# Add ecoregions
```{r}
#| label: 'add-ecoregions'
## Add ecoregions to species list ----
sp_eco_list <- add_ecoregions(sp_list, sp_eco, eco_list)
```
```{r}
#| label: 'print-data-5'
#| echo: false
knitr::kable(head(sp_eco_list, 10), caption = paste("Complete dataset for", params$"mammals_family", "species"))
```
# Count ecoregions
```{r}
#| label: 'count-ecoregions'
## Count ecoregions by species ----
counts_data <- count_ecoregions(sp_eco_list)
```
```{r}
#| label: 'print-data-6'
#| echo: false
knitr::kable(counts_data, caption = paste("Number of ecoregions per", params$"mammals_family", "species"))
```
```{r}
#| label: 'plot-count'
#| out-width: '80%'
#| fig-cap: !expr paste("Number of ecoregions per", params$"mammals_family", "species")
## Barplot ----
plot_counts(counts_data)
```