-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
74 lines (55 loc) · 1.9 KB
/
server.R
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
#library(shinycssloaders)
library(dplyr)
library(reactablefmtr)
source("map.R", local=T)
source("sidebar.R", local=T)
source("table.R", local=T)
pol_oc <- read.csv("./pol_oc.csv")
function(input, output, session) {
rv <- reactiveValues(
pol_oc = NULL,
pol_oc_L = NULL,
theme = NULL
)
observeEvent(
list(
input$side,
input$'dark_mode'),
{
rv$theme = if(input$'dark_mode'==T) {
midnightblue()
} else { nytimes() }
rv$pol_oc <- if(is.null(input$side)) {
tibble(eventDate = character(), scientificName = character(), vernacularName = character(),
longitudeDecimal = numeric(), latitudeDecimal = numeric())} else {
pol_oc %>%
filter(scientificName %in% input$side | vernacularName %in% input$side) }
if(nrow(rv$pol_oc)==0) {
createAlert(
id = "noselect",
options = list(
title = "Alert",
closable = TRUE,
width = 12,
elevations = 4,
status = "primary",
content = "No data available for that selection, or lack thereof. Use the left sidebar to search for something"
)
) } else {
closeAlert(id = "noselect")
}
mapServer("BioMap", rv$pol_oc)
rv$pol_oc_L <- rv$pol_oc %>% mutate(
year = year(ymd(eventDate)),
scientific_vernacular_names = paste0("<b>",scientificName,"</b><br>", vernacularName)) %>%
select(year, scientific_vernacular_names) %>%
group_by(year, scientific_vernacular_names) %>%
summarize(day_cnt = n()) %>%
pivot_wider(names_from = year, values_from = day_cnt)
tabeServer("BioTabe", rv$pol_oc_L, rv$theme)
}
)
output$reactive_sidebar <- renderUI({
sideUI("side", data = pol_oc %>% select(scientificName, vernacularName) )
})
}