Skip to content

Commit 476485f

Browse files
committed
Add deaths to kpi
1 parent 463bccd commit 476485f

File tree

3 files changed

+72
-5
lines changed

3 files changed

+72
-5
lines changed

load_data.R

+59-2
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,66 @@ mapa_ccaa_leaflet <-
383383
leaflet(mapa_ccaa) %>%
384384
addProviderTiles("Stamen.Toner") %>%
385385
addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
386-
group = "CCAA",
386+
group = "Ingresos UCI",
387387
opacity = 1.0, fillOpacity = 0.5,
388388
fillColor = ~colorNumeric("Reds", ingresos_uci)(ingresos_uci),
389389
label = lapply(mapa_ccaa$labs, htmltools::HTML),
390390
highlightOptions = highlightOptions(color = "white", weight = 2,
391-
bringToFront = TRUE))
391+
bringToFront = TRUE)) %>%
392+
addLegend("bottomleft", pal = colorNumeric("Reds", mapa_ccaa$ingresos_uci),
393+
values = ~ingresos_uci,
394+
title = "Ingresos UCI",
395+
group = "Ingresos UCI",
396+
# labFormat = labelFormat(prefix = "$"),
397+
opacity = 1) %>%
398+
399+
addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
400+
group = "Casos",
401+
opacity = 1.0, fillOpacity = 0.5,
402+
fillColor = ~colorNumeric("Blues", casos)(casos),
403+
label = lapply(mapa_ccaa$labs, htmltools::HTML),
404+
highlightOptions = highlightOptions(color = "white", weight = 2,
405+
bringToFront = TRUE)) %>%
406+
addLegend("bottomleft", pal = colorNumeric("Blues", mapa_ccaa$casos),
407+
values = ~casos,
408+
title = "Casos",
409+
group = "Casos",
410+
# labFormat = labelFormat(prefix = "$"),
411+
opacity = 1) %>%
412+
413+
414+
addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
415+
group = "Fallecidos",
416+
opacity = 1.0, fillOpacity = 0.5,
417+
fillColor = ~colorNumeric("Reds", fallecidos)(fallecidos),
418+
label = lapply(mapa_ccaa$labs, htmltools::HTML),
419+
highlightOptions = highlightOptions(color = "white", weight = 2,
420+
bringToFront = TRUE)) %>%
421+
addLegend("bottomright", pal = colorNumeric("Reds", mapa_ccaa$fallecidos),
422+
values = ~fallecidos,
423+
title = "Fallecidos",
424+
group = "Fallecidos",
425+
# labFormat = labelFormat(prefix = "$"),
426+
opacity = 1) %>%
427+
addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
428+
group = "Recuperados",
429+
opacity = 1.0, fillOpacity = 0.5,
430+
fillColor = ~colorNumeric("Greens", recuperados)(recuperados),
431+
label = lapply(mapa_ccaa$labs, htmltools::HTML),
432+
highlightOptions = highlightOptions(color = "white", weight = 2,
433+
bringToFront = TRUE)) %>%
434+
addLegend("bottomright", pal = colorNumeric("Greens", mapa_ccaa$recuperados),
435+
values = ~recuperados,
436+
title = "Recuperados",
437+
group = "Recuperados",
438+
# labFormat = labelFormat(prefix = "$"),
439+
opacity = 1) %>%
440+
441+
# Layers control
442+
addLayersControl(
443+
baseGroups = c("Casos", "Ingresos UCI","Fallecidos","Recuperados" ),
444+
# overlayGroups = c("Quakes", "Outline"),
445+
options = layersControlOptions(collapsed = FALSE)
446+
)
447+
448+

server_dir/simple_kpis_server.R

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
output$contagiados <- renderValueBox({
4-
casos_total <- cvirus_longer %>%
4+
casos_total <- cvirus_map_data %>%
55
filter(fecha == max(fecha)) %>%
66
summarise(casos_total = sum(casos)) %>%
77
pull(casos_total)
@@ -11,10 +11,19 @@ output$contagiados <- renderValueBox({
1111

1212

1313
output$recuperados <- renderValueBox({
14-
recuperados_total <- cvirus_longer %>%
14+
recuperados_total <- cvirus_map_data %>%
1515
filter(fecha == max(fecha)) %>%
1616
summarise(recuperados_total = sum(recuperados)) %>%
1717
pull(recuperados_total)
1818

1919
valueBox(recuperados_total, subtitle = "Recuperados", color = "green")
2020
})
21+
22+
output$fallecidos <- renderValueBox({
23+
fallecidos_total <- cvirus_map_data %>%
24+
filter(fecha == max(fecha)) %>%
25+
summarise(fallecidos_total = sum(fallecidos)) %>%
26+
pull(fallecidos_total)
27+
28+
valueBox(fallecidos_total, subtitle = "Fallecidos", color = "red")
29+
})

ui_dir/map_ui.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ library(shinydashboard)
88
h2("Fecha actualización datos: ") , h2(textOutput("max_fecha")),
99
fluidRow(
1010
valueBoxOutput("contagiados"),
11-
valueBoxOutput("recuperados")
11+
valueBoxOutput("recuperados"),
12+
valueBoxOutput("fallecidos")
1213
),
1314
br(),
1415
h5("Radio círculos = 3 * log( fallecidos + 1 )"),

0 commit comments

Comments
 (0)