--- title: "Analyse de l'incience du syndrome grippal" author: "Olivier Messina" date: "4/25/2020" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r} data_url = "https://www.sentiweb.fr/datasets/incidence-PAY-3.csv" ``` ```{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} data=read.csv(data_url,skip=1, na.strings="-") ``` ```{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),] head(data) ``` ```{r} all(diff(data$date) ==7) ``` ```{r} with(data,plot(date,inc,type="l")) ``` ```{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:2017 ``` ```{r} incidence_annuelle = data.frame(annee = annees, incidence = sapply(annees, pic_annuel)) ``` ```{r} head(incidence_annuelle) ``` ```{r} plot(incidence_annuelle,type="p") ``` ```{r} incidence_annuelle[order(-incidence_annuelle$incidence),] ``` ```{r} hist(incidence_annuelle$incidence,breaks = 10) ```