Exercice 03 (1re partie) : lecture via copie locale

parent 2f0dc9e3
...@@ -2,22 +2,38 @@ ...@@ -2,22 +2,38 @@
title: "Analyse de l'incidence du syndrôme grippal" title: "Analyse de l'incidence du syndrôme grippal"
author: "Konrad Hinsen" author: "Konrad Hinsen"
output: output:
pdf_document: # --- Import des données : copie locale réplicable ---
toc: true
html_document: # URL d’origine (traçabilité uniquement)
toc: true origin_url <- "http://www.sentiweb.fr/datasets/incidence-PAY-3.csv"
theme: journal
documentclass: article # Répertoire local où sauvegarder la copie
classoption: a4paper local_dir <- "module3/exo1/data"
header-includes: dir.create(local_dir, showWarnings = FALSE, recursive = TRUE)
- \usepackage[french]{babel}
- \usepackage[upright]{fourier} # Nom du fichier local
- \hypersetup{colorlinks=true,pagebackref=true} 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 ## Préparation des données
......
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