From 3f271824c89ed70c3573a6920e94873373dec5d9 Mon Sep 17 00:00:00 2001 From: 2391b35e42aa93fb5b9c8666a36d9044 <2391b35e42aa93fb5b9c8666a36d9044@app-learninglab.inria.fr> Date: Sat, 8 Nov 2025 22:32:43 +0000 Subject: [PATCH] Exercice 03 (1re partie) : lecture via copie locale --- module3/exo1/analyse-syndrome-grippal.Rmd | 46 +++++++++++++++-------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/module3/exo1/analyse-syndrome-grippal.Rmd b/module3/exo1/analyse-syndrome-grippal.Rmd index 771e78f..2788592 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 -- 2.18.1