Newer
Older
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
### Ranking tab
##################
### Data objects
##################
TRENDS_tab <- reactive({
date1 <- min(JSON_cons_har$consultation_date)
date2 <- max(JSON_cons_har$consultation_date)
if(input$TRENDStype == "residence_area"){
consultation_har_filter(JSON_cons_har,
new_attack = input$TRENDSnew_attack,
diagn = input$TRENDSdiagn,
sex = input$TRENDSsex,
minAge = input$TRENDSage[1], maxAge = input$TRENDSage[2]
) %>%
select(id_residence_place, consultation_date) %>%
group_by(id_residence_place)
} else if(input$TRENDStype == "center"){
consultation_har_filter(JSON_cons_har,
new_attack = input$TRENDSnew_attack,
diagn = input$TRENDSdiagn,
sex = input$TRENDSsex,
minAge = input$TRENDSage[1], maxAge = input$TRENDSage[2]
) %>%
filter(consultation_date >= date1 & consultation_date <= date2) %>%
select(id_center, consultation_date) %>%
group_by(id_center) %>%
dplyr::summarise(count = n(), trend = decompose(x = consultation_date, date1 = date1, date2 = date2)) %>%
inner_join(healthcenter_list, by = c("id_center" = "id_center"))
} else if(input$TRENDStype == "infection_place"){
consultation_har_filter(JSON_cons_har,
new_attack = input$TRENDSnew_attack,
diagn = input$TRENDSdiagn,
sex = input$TRENDSsex,
minAge = input$TRENDSage[1], maxAge = input$TRENDSage[2]
) %>%
filter(consultation_date >= date1 & consultation_date <= date2) %>%
select(id_infection_place, consultation_date) %>%
group_by(id_infection_place) %>%
dplyr::summarise(count = n(), trend = decompose(x = consultation_date, date1 = date1, date2 = date2)) %>%
inner_join(residencial_area_list, by = c("id_infection_place" = "id"))
}
})
##################
### Table
##################
output$TRENDS_table <- renderDataTable({
TRENDS_tab() %>%
select(name, count, source, trend) %>%
plyr::arrange(-count) %>%
mutate(source = ifelse(source == "BR", tr("BR"), tr("FG"))) %>%
plyr::rename(c("name" = tr("name"), "count" = tr("cases"), "source" = tr("country")))
}, rownames= FALSE)