Commit 97216807 authored by Jerome Dauvergne's avatar Jerome Dauvergne

creating file

parent beb32f85
---
title: "Varicelle"
author: "Jerome E. Dauvergne"
date: "2025-04-28"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Préparation des données
Chargement du fichier depuis le réseau Sentinelle
```{r}
data = read.csv("module3/inc-7-PAY.csv", skip = 1)
```
Regardons :
```{r}
head(data)
tail(data)
```
Données manquantes sur inc ?
```{r}
is.na(data$inc)
```
Non
## Conversion des formats de date
```{r}
library(parsedate)
convert_week = function(w) {
ws = paste(w)
iso = paste0(substring(ws, 1, 4), "-W", substring(ws, 5, 6))
as.character(parse_iso_8601(iso))
}
```
Appliquons cette formule en créant une nouvelle variable date
```{r}
data$date = as.Date(convert_week(data$week))
```
Verifions qu'elle soit bien au format date
```{r}
class(data$date)
```
Reordonnons le fichier dans l'ordre chronologique
```{r}
data <- data[order(data$date),]
```
Toutes les dates ont-elles bien 7 jours d'écart ?
```{r}
all(diff(data$date) == 7)
```
Oui !
## Inspection
```{r}
plot(data$date, data$inc, type="l", xlab="Date", ylab="Incidence hebdomadaire")
```
# Question 1 - Année avec la plus forte épidémie - incidence annuelle
Création d'une fonction pour calculer cette incidence annuelle
```{r}
pic_annuel = function(annee) {
debut = paste0(annee-1,"-01-01")
fin = paste0(annee,"-01-01")
semaines = data$date > debut & data$date <= fin
sum(data$inc[semaines], na.rm=TRUE)
}
```
Appliquons là aux données
```{r}
annees = 1990:2025
inc_annuelle = data.frame(annee = annees,
incidence = sapply(annees, pic_annuel))
head(inc_annuelle)
```
## Inspection visuelle
```{r}
plot(inc_annuelle, type="p", xlab="Année", ylab="Incidence annuelle")
```
Année avec incidence la plus haute
```{r}
inc_annuelle$annee[max(inc_annuelle$incidence)]
```
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