Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8ecd131462db0a88405c9503984c01ac
mooc-rr
Commits
dcf45c20
Commit
dcf45c20
authored
Jun 06, 2026
by
8ecd131462db0a88405c9503984c01ac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update exercice_fr.Rmd
parent
db82b1b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
30 deletions
+12
-30
exercice_fr.Rmd
module3/exo2/exercice_fr.Rmd
+12
-30
No files found.
module3/exo2/exercice_fr.Rmd
View file @
dcf45c20
---
---
title: "Analyse de l'incidence de la varicelle"
title: "Analyse de la varicelle"
author: "HYC"
output: html_document
output:
html_document:
toc: true
theme: journal
pdf_document:
toc: true
documentclass: article
classoption: a4paper
header-includes:
- \usepackage[french]{babel}
- \usepackage[upright]{fourier}
- \hypersetup{colorlinks=true,pagebackref=true}
---
---
```{r}
```{r}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(echo = TRUE)
data_url = "[https://www.sentiweb.fr/datasets/incidence-PAY-7.csv](https://www.sentiweb.fr/datasets/incidence-PAY-7.csv)"
local_file = "varicelle.csv"
local_file = "varicelle.csv"
if (!file.exists(local_file)) { download.file(url = data_url, destfile = local_file, method = "auto") }
data = read.csv(local_file, skip=1, na.strings=c("-"))
data = read.csv(local_file, skip=1, na.strings=c("-"))
head(data)
tail(data)
na_records = apply(data, 1, function (x) any(is.na(x)))
data[na_records,]
class(data$week)
class(data$inc)
library(parsedate)
library(parsedate)
convert_week = function(w) {
convert_week = function(w) {
ws = paste(w)
ws = paste(w)
iso = paste0(substring(ws, 1, 4), "-W", substring(ws, 5, 6))
iso = paste0(substring(ws, 1, 4), "-W", substring(ws, 5, 6))
as.character(parse_iso_8601(iso))
as.character(parse_iso_8601(iso))
}
}
data$date = as.Date(convert_week(data$week))
data$date = as.Date(convert_week(data$week))
class(data$date)
data = data[order(data$date),]
data = data[order(data$date),]
all(diff(data$date) == 7)
plot(data$date, data$inc, type="l", xlab="Date", ylab="Incidence hebdomadaire")
with(tail(data, 200), plot(date, inc, type="l", xlab="Date", ylab="Incidence hebdomadaire"))
pic_annuel = function(annee) {
pic_annuel = function(annee) {
debut = paste0(annee-1,"-09-01")
debut = paste0(annee-1,"-09-01")
fin = paste0(annee,"-09-01")
fin = paste0(annee,"-09-01")
semaines = data$date > debut & data$date <= fin
semaines = data$date > debut & data$date <= fin
sum(data$inc[semaines], na.rm=TRUE)
sum(data$inc[semaines], na.rm=TRUE)
}
}
annees = 1992:2025
annees = 1992:2025
inc_annuelle = data.frame(annee = annees, incidence = sapply(annees, pic_annuel))
inc_annuelle = data.frame(annee = annees, incidence = sapply(annees, pic_annuel))
head(inc_annuelle)
p
lot(inc_annuelle, type="p", xlab="Année", ylab="Incidence annuelle
")
p
rint("--- Epidémie la plus FORTE ---
")
head(inc_annuelle[order(-inc_annuelle$incidence),])
head(inc_annuelle[order(-inc_annuelle$incidence),])
head(inc_annuelle[order(inc_annuelle$incidence),])
hist(inc_annuelle$incidence, breaks=10, xlab="Incidence annuelle", ylab="Nb d'observations", main="")
print("--- Epidémie la plus FAIBLE ---")
\ No newline at end of file
head(inc_annuelle[order(inc_annuelle$incidence),])
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment