From 81e36d63f162d8b145b46b3560e3b0d9b3f9ca7f Mon Sep 17 00:00:00 2001 From: ViktoriiaTan Date: Wed, 15 Jan 2025 14:06:12 +0100 Subject: [PATCH 1/2] Update data source, bind datasets, and adjust total vaccine calculation to include 3d boost and unspecified doses --- R/ds_github.italia.covid19opendatavaccini.R | 30 ++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/R/ds_github.italia.covid19opendatavaccini.R b/R/ds_github.italia.covid19opendatavaccini.R index ff4c474d782..1189dd8fda0 100644 --- a/R/ds_github.italia.covid19opendatavaccini.R +++ b/R/ds_github.italia.covid19opendatavaccini.R @@ -22,8 +22,22 @@ github.italia.covid19opendatavaccini <- function(level){ if(!level %in% 1:2) return(NULL) # download - url <- "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/master/dati/somministrazioni-vaccini-latest.csv" - x <- read.csv(url) + urls <- c("https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2020.csv", + "https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2021.csv", + "https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2022.csv", + "https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2023.csv", + "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-campagna-2023-2024.csv", + "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-campagna-2024-2025.csv" + ) + + x <- do.call(rbind, { + all_cols <- unique(unlist(lapply(urls, function(url) names(read.csv(url))))) + lapply(urls, function(url) { + df <- read.csv(url) + df[setdiff(all_cols, names(df))] <- NA + df[all_cols] + }) + }) # format x <- map_data(x, c( @@ -34,13 +48,21 @@ github.italia.covid19opendatavaccini <- function(level){ "d2" = "second", "dpi" = "oneshot", "db1" = "extra_1", - "db2" = "extra_2" + "db2" = "extra_2", + "db3" = "extra_3", + "d" = "unsp_dose" )) # people vaccinated and total doses x <- x %>% dplyr::mutate( - vaccines = first + second + oneshot + extra_1 + extra_2, + vaccines = coalesce(first, 0) + + coalesce(second, 0) + + coalesce(oneshot, 0) + + coalesce(extra_1, 0) + + coalesce(extra_2, 0) + + coalesce(extra_3, 0) + + coalesce(unsp_dose, 0), people_vaccinated = first + oneshot, people_fully_vaccinated = second + oneshot + first*(type=="Janssen")) From ac179e4ffee67881ae3bf04389783817905c037b Mon Sep 17 00:00:00 2001 From: Emanuele Guidotti Date: Wed, 15 Jan 2025 22:20:27 +0100 Subject: [PATCH 2/2] Update ds_github.italia.covid19opendatavaccini.R --- R/ds_github.italia.covid19opendatavaccini.R | 23 +++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/R/ds_github.italia.covid19opendatavaccini.R b/R/ds_github.italia.covid19opendatavaccini.R index 1189dd8fda0..f0f69349084 100644 --- a/R/ds_github.italia.covid19opendatavaccini.R +++ b/R/ds_github.italia.covid19opendatavaccini.R @@ -22,22 +22,15 @@ github.italia.covid19opendatavaccini <- function(level){ if(!level %in% 1:2) return(NULL) # download - urls <- c("https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2020.csv", - "https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2021.csv", - "https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2022.csv", - "https://github.com/italia/covid19-opendata-vaccini/raw/refs/heads/master/dati/somministrazioni-vaccini-latest-2023.csv", + urls <- c("https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-2020.csv", + "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-2021.csv", + "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-2022.csv", + "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-2023.csv", "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-campagna-2023-2024.csv", "https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/refs/heads/master/dati/somministrazioni-vaccini-latest-campagna-2024-2025.csv" ) - - x <- do.call(rbind, { - all_cols <- unique(unlist(lapply(urls, function(url) names(read.csv(url))))) - lapply(urls, function(url) { - df <- read.csv(url) - df[setdiff(all_cols, names(df))] <- NA - df[all_cols] - }) - }) + + x <- dplyr::bind_rows(lapply(urls, read.csv)) # format x <- map_data(x, c( @@ -63,8 +56,8 @@ github.italia.covid19opendatavaccini <- function(level){ coalesce(extra_2, 0) + coalesce(extra_3, 0) + coalesce(unsp_dose, 0), - people_vaccinated = first + oneshot, - people_fully_vaccinated = second + oneshot + first*(type=="Janssen")) + people_vaccinated = first + oneshot, + people_fully_vaccinated = second + oneshot + first*(type=="Janssen")) if(level==1){