--- title: "Exercice 2 du Module 3" author: "Auriane Mens" date: "16/11/2025" output: html_document --- --- title: "Exercice 2 Module 3" author: "Auriane Mens" date: "2025-11-16" output: html_document --- data_urlvar = "https://www.sentiweb.fr/datasets/all/inc-7-REG-ds2.json" data =read.csv(data_urlvar, skip=1) data <- read.csv("varicelle.csv") data <- read.csv("C:\Users\auria\OneDrive - Institut Catholique de Lille\Documents\Master Recherche et Innovation en Santé\Master 2\MOOC Reproductibilité en recherche\mooc-rr\module3\exo2\varicelle.csv") data <- read.csv("C:/Users/auria/OneDrive - Institut Catholique de Lille/Documents/Master Recherche et Innovation en Santé/Master 2/MOOC Reproductibilité en recherche/mooc-rr/module3/exo2/varicelle.csv", sep = ;) head(data) data <- read.csv("/mnt/data/inc-7-PAY.csv", sep = ";") data <- read.csv("C:/Users/auria/OneDrive - Institut Catholique de Lille/Documents/Master Recherche et Innovation en Santé/Master 2/MOOC Reproductibilité en recherche/mooc-rr/module3/exo2/varicelle.csv", sep = ";") head(data) str(data) library(ISOweek) data$date <- ISOweek2date(paste0(data$week, "-1")) data$year_epi <- ifelse( format(data$date, "%m") >= "09", as.numeric(format(data$date, "%Y")), as.numeric(format(data$date, "%Y")) - 1 ) # Lire le fichier CSV téléchargé depuis Sentinelles data <- read.csv("varicelle.csv") data$date <- as.Date(data$date) ### ------------------------------- ### 2. Construire les années épidémiques (le 1er septembre comme début de chaque période annuelle) # Une année épidémique commence le 1er septembre : # Si mois >= 9 ⇒ année_epidémique = année en cours # Sinon ⇒ année_epidémique = année - 1 data$year_epi <- ifelse(format(data$date, "%m") >= "09", format(data$date, "%Y"), as.numeric(format(data$date, "%Y")) - 1) ### Convertir en nombre pour éviter les problèmes data$year_epi <- as.numeric(data$year_epi) ### ------------------------------- ### 3. Calcul du pic épidémique par année ### ------------------------------- library(dplyr) peaks <- data %>% group_by(year_epi) %>% summarise( max_inc = max(inc, na.rm = TRUE), mean_inc = mean(inc, na.rm = TRUE), total_inc = sum(inc, na.rm = TRUE) ) print(peaks) ### 4. Trouver l'année la plus forte et la plus faible # Selon le pic hebdomadaire (max_inc) year_strongest <- peaks$year_epi[which.max(peaks$max_inc)] year_weakest <- peaks$year_epi[which.min(peaks$max_inc)] cat("Année épidémique la plus forte :", year_strongest, "\n") 2009 cat("Année épidémique la plus faible :", year_weakest, "\n") 2020 ``` Et