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
70e69c47b2b381042ccc48e49e7fc9b5
mooc-rr
Commits
4c4693bf
Commit
4c4693bf
authored
May 15, 2020
by
Ana Sodan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exercice 2 module 3
parent
870905c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
0 deletions
+122
-0
AnalyseSyndrome_AS.Rmd
module3/exo1/AnalyseSyndrome_AS.Rmd
+122
-0
No files found.
module3/exo1/AnalyseSyndrome_AS.Rmd
0 → 100644
View file @
4c4693bf
---
title: "Analyse de l'incidence su syndrôme grippal"
author: '*Ana Sodan*'
date: "08/05/2020"
output: html_document
editor_options:
chunk_output_type: inline
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
data_url="https://www.sentiweb.fr/datasets/incidence-PAY-3.csv"
```
```{r}
data_file="syndrome-grippal.csv"
if(!file.exists(data_file)){download.file(data_url,data_file,method="auto")}
```
```{r}
data=read.csv(data_url,skip=1)
head (data)
```
```{r}
tail(data)
```
```{r}
lignes_na=apply(data,1,function(x)any(is.na(x)))
data[lignes_na,]
```
```{r}
class(data$week)
```
```{r}
class(data$inc)
```
```{r}
library(parsedate)
```
```{r}
convert_week=function(date){ ws=paste(date)
iso=paste0(substring(ws,1,4),"-W",substring(ws,5,6))
as.character(parse_iso_8601(iso))}
```
```{r}
data$date=as.Date(sapply(data$week,convert_week))
```
```{r}
class(data$date)
```
```{r}
data=data[order(data$date),]
```
```{r}
head(data)
```
Pour vérifier que la distance entre deux dates est bien 7 jours
```{r}
all(diff(data$date)==7)
```
```{r}
with(data,plot(date,inc,type="l"))
```
On peut appliquer cela juste sur les dernières données. Exemple sur les 200 dernières.
```{r}
with(tail(data,200),plot(date,inc,type="l"))
```
```{r}
pic_annuel=function(annee){
debut=paste0(annee-1,"-08-01")
fin =paste0(annee,"-08-01")
semaines=data$date>debut & data$date<=fin
sum(data$inc[semaines],na.rm=TRUE)}
```
```{r}
annees=1986:2019
```
```{r}
incidence_annuelle=data.frame(annee=annees,incidence=sapply(annees,pic_annuel))
```
```{r}
head(incidence_annuelle)
```
```{r}
plot(incidence_annuelle,"p")
```
```{r}
head(incidence_annuelle[order(-incidence_annuelle$incidence),])
```
Dans Hist Breaks signifie le nombre de barres que l'on veut avoir.
```{r}
hist(incidence_annuelle$incidence,breaks=10)
```
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