-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard_Sol.Rmd
67 lines (54 loc) · 1.3 KB
/
dashboard_Sol.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
---
title: "Awesome dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r}
library(flexdashboard)
library(raster)
library(tmap)
library(plotly)
library(leaflet)
hyp <- raster('data/Hypoxia.tif')
acid <- raster('data/Acidification.tif')
fish <- raster('data/FisheriesDD.tif')
rstack <- stack(hyp, acid)
```
## Column {data-width=500}
### Awesome chart 1
```{r}
tmap_mode('view')
tm_shape(rstack) +
tm_raster(title = c("Hypoxia",
"Acidification")) +
tm_facets(as.layers = TRUE,
free.scales.raster = TRUE)
```
### Magnificent chart 2
```{r}
leaflet() %>%
setView(lng = -63.6118, lat = 44.6828, zoom = 5) %>%
addProviderTiles('Esri.OceanBasemap', group = 'Ocean') %>%
addRasterImage(fish, group = 'Fish') %>%
# Reset layer selection
addLayersControl(baseGroups = c('Ocean', 'Topo'),
overlayGroups = c('Fish'),
position = 'topleft')
```
## Column {data-width=500}
### Incredible chart 3
```{r}
plot_ly(alpha = 0.6, nbinsx = 30) %>%
add_histogram(x = values(hyp), name = 'Hypoxia') %>%
add_histogram(x = values(acid), name = 'Acidification') %>%
layout(barmode = "overlay")
```
### Ok chart 4
```{r}
s <- sum(rstack, na.rm = TRUE)
s[is.na(values(acid))] <- NA
tm_shape(s) +
tm_raster(title = "Cumulative exposure")
```