diff --git a/module3/exo1/analyse-syndrome-grippal.Rmd b/module3/exo1/analyse-syndrome-grippal.Rmd index 771e78faac371f23c921f7f7aecc87f2100e9059..2788592c80d8ef8d079834c348c958930d74632a 100644 --- a/module3/exo1/analyse-syndrome-grippal.Rmd +++ b/module3/exo1/analyse-syndrome-grippal.Rmd @@ -2,22 +2,38 @@ title: "Analyse de l'incidence du syndrôme grippal" author: "Konrad Hinsen" output: - pdf_document: - toc: true - html_document: - toc: true - theme: journal -documentclass: article -classoption: a4paper -header-includes: -- \usepackage[french]{babel} -- \usepackage[upright]{fourier} -- \hypersetup{colorlinks=true,pagebackref=true} ---- + # --- Import des données : copie locale réplicable --- + +# URL d’origine (traçabilité uniquement) +origin_url <- "http://www.sentiweb.fr/datasets/incidence-PAY-3.csv" + +# Répertoire local où sauvegarder la copie +local_dir <- "module3/exo1/data" +dir.create(local_dir, showWarnings = FALSE, recursive = TRUE) + +# Nom du fichier local +local_csv <- file.path(local_dir, "incidence_fr_metropolitaine.csv") + +# 1) Télécharger si la copie locale n’existe pas +if (!file.exists(local_csv)) { + message("Téléchargement depuis le Réseau Sentinelles…") + utils::download.file(origin_url, destfile = local_csv, mode = "wb", quiet = TRUE) +} + +# 2) Lire la copie locale +data <- read.csv(local_csv, + skip = 1, + na.strings = c("-", "", "NA"), + stringsAsFactors = FALSE) + +names(data) <- trimws(tolower(names(data))) +if (!"inc" %in% names(data) && "inc100" %in% names(data)) { + data$inc <- data$inc100 +} + +stopifnot(all(c("week", "inc") %in% names(data))) +head(data) -```{r setup, include=FALSE} -knitr::opts_chunk$set(echo = TRUE) -``` ## Préparation des données