Commit cfd44870 authored by numeroteca's avatar numeroteca

update dashboard, por fin!

parent 4bd9cc15
This diff is collapsed.
......@@ -13,8 +13,7 @@ library(flexdashboard)
library(tidyverse)
library(plotly)
# Este archivo era antes "evolution_spain_provinces.R"
library(tidyverse)
# library(tidyverse)
library(reshape2)
# library(ggrepel) # for geom_text_repel to prevent overlapping
......@@ -24,8 +23,8 @@ library(reshape2)
caption_en <- "By: lab.montera34.com/covid19 | Data: esCOVID19data. Check code.montera34.com/covid19"
caption_provincia <- "Gráfico: @numeroteca (lab.montera34.com/covid19) | Datos: esCOVID19data (github.com/montera34/escovid19data)"
updated <- ""
period <- "(Actualizado: 2021-02-05)"
filter_date <- as.Date("2021-02-06")
period <- "(Actualizado: 2021-02-06)"
filter_date <- as.Date("2021-02-07")
# Load data:
data_cases_sp_provinces <- readRDS(file = "../data/output/spain/covid19-provincias-spain_consolidated.rds")
......@@ -76,7 +75,7 @@ Row {.tabset .tabset-fade}
```{r}
p <- data_cases_sp_provinces %>% mutate(
cases_PCR_14days = ifelse( ccaa=="Galicia" | ccaa=="Andalucía", cases_14days, cases_PCR_14days)
) %>% ungroup(province) %>% filter( !(is.na(ia14) & date > as.Date("2020-08-10") ) ) %>%
) %>% filter( !(is.na(ia14) & date > as.Date("2020-08-10") ) ) %>%
ggplot() +
# geom_line(aes(date, daily_cases,group=province, color=ccaa), size= 0.8 ) +
geom_line( aes(date, ia14,group=province, color=ccaa, text = paste0("<b>", province, " (", ccaa, ")</b><br>", format( round(ia14, digits = 1),
......@@ -155,7 +154,7 @@ Nota: Galicia, Andalucía, Aragón y C. Valenciana no diferencian entre PCR+ y o
```{r}
p <- data_cases_sp_provinces %>% mutate(
cases_PCR_14days = ifelse( ccaa=="Galicia" | ccaa=="Andalucía", cases_14days, cases_PCR_14days)
) %>% ungroup(province) %>% filter( !(is.na(ia14) & date > as.Date("2020-08-10") ) ) %>%
) %>% filter( !(is.na(ia14) & date > as.Date("2020-08-10") ) ) %>%
ggplot() +
# geom_line(aes(date, daily_cases,group=province, color=ccaa), size= 0.8 ) +
geom_line( aes(date, ia14,group=province, color=ccaa, text = paste0("<b>", province, " (", ccaa, ")</b><br>", format( round(ia14, digits = 1),
......@@ -238,7 +237,7 @@ Row {.tabset .tabset-fade}
### Casos / día
```{r}
interactive_dp <- data_cases_sp_provinces %>% ungroup(province) %>%
interactive_dp <- data_cases_sp_provinces %>%
mutate(
daily_cases_PCR_avg7 = ifelse( date > as.Date("2020-10-02") & is.na(daily_cases_PCR_avg7), daily_cases_avg7, daily_cases_PCR_avg7 )
) %>% filter( !(is.na(daily_cases_PCR_avg7) & date > as.Date("2020-08-10") ) ) %>%
......@@ -255,7 +254,7 @@ interactive_dp <- data_cases_sp_provinces %>% ungroup(province) %>%
scale_color_manual(values = colors_prov) +
coord_cartesian(
# ylim = c(1, max(data_cases_sp_provinces[!is.na(data_cases_sp_provinces$daily_cases_PCR_avg7) & (date > data_cases_sp_provinces$filter_date - 50),]$daily_cases_PCR_avg7) )
ylim = c(0, 4300 )
ylim = c(0, 5200 )
) +
scale_y_continuous( labels=function(x) format(round(x, digits = 0), big.mark = ".", scientific = FALSE),
# minor_breaks = c(seq(1 , 10, 1),seq(10 , 100, 10), seq(100 , 1000, 100), seq(1000 , 10000, 1000)),
......@@ -304,7 +303,7 @@ Se usan casos PCR+, menos las CCAA que empezaron a usar test de antígenos a par
### Casos / día (últimos días)
```{r}
interactive_dp <- data_cases_sp_provinces %>% ungroup(province) %>%
interactive_dp <- data_cases_sp_provinces %>%
filter ( date > filter_date - 50 ) %>%
mutate(
daily_cases_PCR_avg7 = ifelse( date > as.Date("2020-10-02") & is.na(daily_cases_PCR_avg7), daily_cases_avg7, daily_cases_PCR_avg7 )
......@@ -322,7 +321,7 @@ interactive_dp <- data_cases_sp_provinces %>% ungroup(province) %>%
scale_color_manual(values = colors_prov) +
coord_cartesian(
# ylim = c(1, max(data_cases_sp_provinces[!is.na(data_cases_sp_provinces$daily_cases_PCR_avg7) & (date > data_cases_sp_provinces$filter_date - 50),]$daily_cases_PCR_avg7) )
ylim = c(0, 4200 )
ylim = c(0, 5200 )
) +
scale_y_continuous( labels=function(x) format(round(x, digits = 0), big.mark = ".", scientific = FALSE),
# minor_breaks = c(seq(1 , 10, 1),seq(10 , 100, 10), seq(100 , 1000, 100), seq(1000 , 10000, 1000)),
......@@ -371,7 +370,7 @@ Se usan casos PCR+, menos las CCAA que empezaron a usar test de antígenos a par
### Casos / día Log
```{r}
interactive_dp <- data_cases_sp_provinces %>% ungroup(province) %>% mutate(
interactive_dp <- data_cases_sp_provinces %>% mutate(
daily_cases_PCR_avg7 = ifelse( date > as.Date("2020-10-02") & is.na(daily_cases_PCR_avg7), daily_cases_avg7, daily_cases_PCR_avg7 )
) %>% filter( !(is.na(daily_cases_PCR_avg7) & date > as.Date("2020-08-10") ) ) %>%
ggplot() +
......@@ -440,7 +439,7 @@ p2 <- data_cases_sp_provinces %>% mutate(
cases_PCR_14days = ifelse( ccaa=="Galicia" | ccaa=="Andalucía", cases_14days, cases_PCR_14days)
) %>% mutate(
cases_PCR_14days = ifelse( date > as.Date("2020-10-02") & is.na(cases_PCR_14days), cases_14days, cases_PCR_14days )
) %>% ungroup(province) %>% filter( !(is.na(daily_cases_PCR_avg7) & date > as.Date("2020-08-10") ) ) %>%
) %>% filter( !(is.na(daily_cases_PCR_avg7) & date > as.Date("2020-08-10") ) ) %>%
ggplot() +
geom_line(aes(date, cases_PCR_14days,group=province, color=ccaa, text = paste0("<b>", province, " (", ccaa, ")</b><br>", format( round(cases_PCR_14days, digits = 1),
big.mark=".", decimal.mark = ","), " casos en 14 días" ,"<br>",date )), size= 0.4 ) +
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment