-
Notifications
You must be signed in to change notification settings - Fork 0
/
time-series.qmd
148 lines (126 loc) · 3.17 KB
/
time-series.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
---
title: "Everglades Time Series"
format: dashboard
echo: false
---
```{r}
library(wader)
#download_observations(".")
```
```{r}
library(dplyr)
library(tibble)
library(tidyr)
colony_counts <- tibble(max_counts(level = "colony"))
subregion_counts <- tibble(max_counts(level = "subregion"))
region_counts <- tibble(max_counts(level = "region"))
everglades_counts <- tibble(max_counts(level = "all"))
water <- tibble(load_datafile("Water/eden_covariates.csv"))
subregion_counts <- subregion_counts |>
filter(species %in% c("gbhe", "greg", "rosp", "sneg", "wost", "whib")) |>
group_by(region) |>
filter(n_distinct(year) > 10) |>
complete(year = full_seq(year, 1), species, fill = list(count = 0)) |>
ungroup()
ojs_define(col_counts = colony_counts)
ojs_define(sub_counts = subregion_counts)
ojs_define(reg_counts = region_counts)
ojs_define(ever_counts = everglades_counts)
ojs_define(enviro_data = water)
```
# Max Counts
## {.sidebar}
```{ojs}
viewof min_year = Inputs.range(
[1986, 2024],
{step: 1, value: 1986, label: "Min year"})
viewof max_year = Inputs.range(
[1986, 2024],
{step: 1, value: 2024, label: "Max year"})
viewof species = Inputs.checkbox(
["greg", "whib", "rosp", "sneg", "wost", "gbhe"],
{ value: ["greg", "whib", "rosp", "sneg", "wost", "gbhe"],
label: "Species:"
}
)
```
```{ojs}
//| output: false
data = transpose(sub_counts)
/*
viewof scale = Inputs.select(
["colony", "subregion", "region", "all"],
{value: "subregion", label: "Scale:"}
)
*/
filtered = data.filter(function(df) {
return df.year >= min_year &&
df.year <= max_year &&
species.includes(df.species)
})
```
## Row
```{ojs}
Plot.plot({
x: {tickFormat: d => d.toString()},
marks: [
Plot.line(filtered, {
x: "year",
y: "count",
stroke: "species",
fy: "region",
marker: true
})
],
legend: {
title: "Species",
orient: "top",
stroke: "species",
symbol: "stroke"
}
})
```
# Water Data
## {.sidebar}
```{ojs}
viewof env_min_year = Inputs.range(
[1986, 2024],
{step: 1, value: 1986, label: "Min year"})
viewof env_max_year = Inputs.range(
[1986, 2024],
{step: 1, value: 2024, label: "Max year"})
viewof env_variable = Inputs.select(
["init_depth", "breed_season_depth", "recession", "pre_recession", "post_recession", "dry_days"],
{ value: "init_depth", label: "Variables:"}
)
viewof region = Inputs.checkbox(
env_data.map(d => d.region).filter((value, index, self) => self.indexOf(value) === index),
{ value: env_data.map(d => d.region).filter((value, index, self) => self.indexOf(value) === index), label: "Region:" }
)
```
```{ojs}
//| output: false
env_data = transpose(enviro_data)
env_filtered = env_data.filter(function(df) {
return df.year >= env_min_year &&
df.year <= env_max_year &&
region.includes(df.region)
})
```
## Row
```{ojs}
Plot.plot({
gird: true,
x: {tickFormat: d => d.toString()},
marks: [
Plot.frame(),
Plot.line(env_filtered, {
x: "year",
y: d => d[env_variable],
stroke: "steelblue",
fy: "region",
marker: true
})
]}
)
```