Commit 84357140 authored by Loick Klpr's avatar Loick Klpr

Réalisation des exos du module 3

parent 3b83e939
......@@ -2,11 +2,11 @@
title: "Analyse de l'incidence du syndrôme grippal"
author: "Konrad Hinsen"
output:
pdf_document:
toc: true
html_document:
toc: true
theme: journal
pdf_document:
toc: true
documentclass: article
classoption: a4paper
header-includes:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
a4paper]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Analyse de l'incidence du syndrôme grippal},
pdfauthor={Konrad Hinsen},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\usepackage{longtable,booktabs}
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\usepackage[french]{babel}
\usepackage[upright]{fourier}
\hypersetup{colorlinks=true,pagebackref=true}
\title{Analyse de l'incidence du syndrôme grippal}
\author{Konrad Hinsen}
\date{}
\begin{document}
\maketitle
{
\setcounter{tocdepth}{2}
\tableofcontents
}
\hypertarget{pruxe9paration-des-donnuxe9es}{%
\subsection{Préparation des
données}\label{pruxe9paration-des-donnuxe9es}}
Les données de l'incidence du syndrome grippal sont disponibles du site
Web du \href{http://www.sentiweb.fr/}{Réseau Sentinelles}. Nous les
récupérons sous forme d'un fichier en format CSV dont chaque ligne
correspond à une semaine de la période demandée. Nous téléchargeons
toujours le jeu de données complet, qui commence en 1984 et se termine
avec une semaine récente. L'URL est:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{data_url =}\StringTok{ "http://www.sentiweb.fr/datasets/incidence-PAY-3.csv"}
\end{Highlighting}
\end{Shaded}
Data url local
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{data_url_local =}\StringTok{ "D:/PhD/formation recherche reproductible/mooc-rr/module3/exo1/incidence-PAY-3.csv"}
\end{Highlighting}
\end{Shaded}
Voici l'explication des colonnes donnée sur le
\href{https://ns.sentiweb.fr/incidence/csv-schema-v1.json}{sur le site
d'origine}:
\begin{longtable}[]{@{}ll@{}}
\toprule
\begin{minipage}[b]{0.10\columnwidth}\raggedright
Nom de colonne\strut
\end{minipage} & \begin{minipage}[b]{0.84\columnwidth}\raggedright
Libellé de colonne\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{week}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Semaine calendaire (ISO 8601)\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{indicator}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Code de l'indicateur de surveillance\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{inc}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Estimation de l'incidence de consultations en nombre de cas\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{inc\_low}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Estimation de la borne inférieure de l'IC95\% du nombre de cas de
consultation\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{inc\_up}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Estimation de la borne supérieure de l'IC95\% du nombre de cas de
consultation\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{inc100}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Estimation du taux d'incidence du nombre de cas de consultation (en cas
pour 100,000 habitants)\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{inc100\_low}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Estimation de la borne inférieure de l'IC95\% du taux d'incidence du
nombre de cas de consultation (en cas pour 100,000 habitants)\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{inc100\_up}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Estimation de la borne supérieure de l'IC95\% du taux d'incidence du
nombre de cas de consultation (en cas pour 100,000 habitants)\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{geo\_insee}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Code de la zone géographique concernée (Code INSEE)
\url{http://www.insee.fr/fr/methodes/nomenclatures/cog/}\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.10\columnwidth}\raggedright
\texttt{geo\_name}\strut
\end{minipage} & \begin{minipage}[t]{0.84\columnwidth}\raggedright
Libellé de la zone géographique (ce libellé peut être modifié sans
préavis)\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}
La première ligne du fichier CSV est un commentaire, que nous ignorons
en précisant \texttt{skip=1}. \#\#\# Téléchargement
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{data =}\StringTok{ }\KeywordTok{read.csv}\NormalTok{(data_url, }\DataTypeTok{skip=}\DecValTok{1}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
Lecture des données en locale
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{data_locale =}\StringTok{ }\KeywordTok{read.csv}\NormalTok{(data_url_local, }\DataTypeTok{skip =} \DecValTok{1}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
Regardons ce que nous avons obtenu:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{head}\NormalTok{(data)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## week indicator inc inc_low inc_up inc100 inc100_low inc100_up geo_insee
## 1 202105 3 22491 18436 26546 34 28 40 FR
## 2 202104 3 25804 21491 30117 39 32 46 FR
## 3 202103 3 21810 17894 25726 33 27 39 FR
## 4 202102 3 17320 13906 20734 26 21 31 FR
## 5 202101 3 21799 17778 25820 33 27 39 FR
## 6 202053 3 21220 16498 25942 32 25 39 FR
## geo_name
## 1 France
## 2 France
## 3 France
## 4 France
## 5 France
## 6 France
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{tail}\NormalTok{(data)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## week indicator inc inc_low inc_up inc100 inc100_low inc100_up
## 1888 198449 3 101073 81684 120462 184 149 219
## 1889 198448 3 78620 60634 96606 143 110 176
## 1890 198447 3 72029 54274 89784 131 99 163
## 1891 198446 3 87330 67686 106974 159 123 195
## 1892 198445 3 135223 101414 169032 246 184 308
## 1893 198444 3 68422 20056 116788 125 37 213
## geo_insee geo_name
## 1888 FR France
## 1889 FR France
## 1890 FR France
## 1891 FR France
## 1892 FR France
## 1893 FR France
\end{verbatim}
Y a-t-il des points manquants dans nos données ?
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{na_records =}\StringTok{ }\KeywordTok{apply}\NormalTok{(data, }\DecValTok{1}\NormalTok{, }\ControlFlowTok{function}\NormalTok{ (x) }\KeywordTok{any}\NormalTok{(}\KeywordTok{is.na}\NormalTok{(x)))}
\NormalTok{data[na_records,]}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## week indicator inc inc_low inc_up inc100 inc100_low inc100_up geo_insee
## 1657 198919 3 0 NA NA 0 NA NA FR
## geo_name
## 1657 France
\end{verbatim}
Les deux colonnes qui nous intéressent sont \texttt{week} et
\texttt{inc}. Vérifions leurs classes:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{class}\NormalTok{(data}\OperatorTok{$}\NormalTok{week)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] "integer"
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{class}\NormalTok{(data}\OperatorTok{$}\NormalTok{inc)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] "integer"
\end{verbatim}
Ce sont des entiers, tout va bien !
\hypertarget{conversion-des-numuxe9ros-de-semaine}{%
\subsubsection{Conversion des numéros de
semaine}\label{conversion-des-numuxe9ros-de-semaine}}
La gestion des dates est toujours un sujet délicat. Il y a un grand
nombre de conventions différentes qu'il ne faut pas confondre. Notre
jeux de données utilise un format que peu de logiciels savent traiter:
les semaines en format
\href{https://en.wikipedia.org/wiki/ISO_8601}{ISO-8601}. En \texttt{R},
il est géré par la bibliothèque
\href{https://cran.r-project.org/package=parsedate}{parsedate}:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(parsedate)}
\end{Highlighting}
\end{Shaded}
Pour faciliter le traitement suivant, nous remplaçons ces semaines par
les dates qui correspondent aux lundis. Voici une petite fonction qui
fait la conversion pour une seule valeur:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{convert_week =}\StringTok{ }\ControlFlowTok{function}\NormalTok{(w) \{}
\NormalTok{ ws =}\StringTok{ }\KeywordTok{paste}\NormalTok{(w)}
\NormalTok{ iso =}\StringTok{ }\KeywordTok{paste0}\NormalTok{(}\KeywordTok{substring}\NormalTok{(ws, }\DecValTok{1}\NormalTok{, }\DecValTok{4}\NormalTok{), }\StringTok{"-W"}\NormalTok{, }\KeywordTok{substring}\NormalTok{(ws, }\DecValTok{5}\NormalTok{, }\DecValTok{6}\NormalTok{))}
\KeywordTok{as.character}\NormalTok{(}\KeywordTok{parse_iso_8601}\NormalTok{(iso))}
\NormalTok{\}}
\end{Highlighting}
\end{Shaded}
Nous appliquons cette fonction à tous les points, créant une nouvelle
colonne \texttt{date} dans notre jeu de données:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{data}\OperatorTok{$}\NormalTok{date =}\StringTok{ }\KeywordTok{as.Date}\NormalTok{(}\KeywordTok{convert_week}\NormalTok{(data}\OperatorTok{$}\NormalTok{week))}
\end{Highlighting}
\end{Shaded}
Vérifions qu'elle est de classe \texttt{Date}:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{class}\NormalTok{(data}\OperatorTok{$}\NormalTok{date)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] "Date"
\end{verbatim}
Les points sont dans l'ordre chronologique inverse, il est donc utile de
les trier:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{data =}\StringTok{ }\NormalTok{data[}\KeywordTok{order}\NormalTok{(data}\OperatorTok{$}\NormalTok{date),]}
\end{Highlighting}
\end{Shaded}
C'est l'occasion pour faire une vérification: nos dates doivent être
séparées d'exactement sept jours:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{all}\NormalTok{(}\KeywordTok{diff}\NormalTok{(data}\OperatorTok{$}\NormalTok{date) }\OperatorTok{==}\StringTok{ }\DecValTok{7}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] TRUE
\end{verbatim}
\hypertarget{inspection}{%
\subsubsection{Inspection}\label{inspection}}
Regardons enfin à quoi ressemblent nos données !
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{plot}\NormalTok{(data}\OperatorTok{$}\NormalTok{date, data}\OperatorTok{$}\NormalTok{inc, }\DataTypeTok{type=}\StringTok{"l"}\NormalTok{, }\DataTypeTok{xlab=}\StringTok{"Date"}\NormalTok{, }\DataTypeTok{ylab=}\StringTok{"Incidence hebdomadaire"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\includegraphics{analyse-syndrome-grippal_files/figure-latex/unnamed-chunk-14-1.pdf}
Un zoom sur les dernières années montre mieux la localisation des pics
en hiver. Le creux des incidences se trouve en été.
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{with}\NormalTok{(}\KeywordTok{tail}\NormalTok{(data, }\DecValTok{200}\NormalTok{), }\KeywordTok{plot}\NormalTok{(date, inc, }\DataTypeTok{type=}\StringTok{"l"}\NormalTok{, }\DataTypeTok{xlab=}\StringTok{"Date"}\NormalTok{, }\DataTypeTok{ylab=}\StringTok{"Incidence hebdomadaire"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\includegraphics{analyse-syndrome-grippal_files/figure-latex/unnamed-chunk-15-1.pdf}
\hypertarget{lincidence-annuelle}{%
\subsection{L'incidence annuelle}\label{lincidence-annuelle}}
\hypertarget{calcul}{%
\subsubsection{Calcul}\label{calcul}}
Étant donné que le pic de l'épidémie se situe en hiver, à cheval entre
deux années civiles, nous définissons la période de référence entre deux
minima de l'incidence, du 1er août de l'année \(N\) au 1er août de
l'année \(N+1\). Nous mettons l'année \(N+1\) comme étiquette sur cette
année décalée, car le pic de l'épidémie est toujours au début de l'année
\(N+1\). Comme l'incidence de syndrome grippal est très faible en été,
cette modification ne risque pas de fausser nos conclusions. L'argument
\texttt{na.rm=True} dans la sommation précise qu'il faut supprimer les
points manquants. Ce choix est raisonnable car il n'y a qu'un seul point
manquant, dont l'impact ne peut pas être très fort.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{pic_annuel =}\StringTok{ }\ControlFlowTok{function}\NormalTok{(annee) \{}
\NormalTok{ debut =}\StringTok{ }\KeywordTok{paste0}\NormalTok{(annee}\DecValTok{-1}\NormalTok{,}\StringTok{"-08-01"}\NormalTok{)}
\NormalTok{ fin =}\StringTok{ }\KeywordTok{paste0}\NormalTok{(annee,}\StringTok{"-08-01"}\NormalTok{)}
\NormalTok{ semaines =}\StringTok{ }\NormalTok{data}\OperatorTok{$}\NormalTok{date }\OperatorTok{>}\StringTok{ }\NormalTok{debut }\OperatorTok{&}\StringTok{ }\NormalTok{data}\OperatorTok{$}\NormalTok{date }\OperatorTok{<=}\StringTok{ }\NormalTok{fin}
\KeywordTok{sum}\NormalTok{(data}\OperatorTok{$}\NormalTok{inc[semaines], }\DataTypeTok{na.rm=}\OtherTok{TRUE}\NormalTok{)}
\NormalTok{ \}}
\end{Highlighting}
\end{Shaded}
Nous devons aussi faire attention aux premières et dernières années de
notre jeux de données. Les données commencent en octobre 1984, ce qui ne
permet pas de quantifier complètement le pic attribué à 1985. Nous
l'enlevons donc de notre analyse. Par contre, pour une exécution en
octobre 2018, les données se terminent après le 1er août 2018, ce qui
nous permet d'inclure cette année.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{annees =}\StringTok{ }\DecValTok{1986}\OperatorTok{:}\DecValTok{2018}
\end{Highlighting}
\end{Shaded}
Nous créons un nouveau jeu de données pour l'incidence annuelle, en
applicant la fonction \texttt{pic\_annuel} à chaque année:
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{inc_annuelle =}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\DataTypeTok{annee =}\NormalTok{ annees,}
\DataTypeTok{incidence =} \KeywordTok{sapply}\NormalTok{(annees, pic_annuel))}
\KeywordTok{head}\NormalTok{(inc_annuelle)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## annee incidence
## 1 1986 5100540
## 2 1987 2861556
## 3 1988 2766142
## 4 1989 5460155
## 5 1990 5233987
## 6 1991 1660832
\end{verbatim}
\hypertarget{inspection-1}{%
\subsubsection{Inspection}\label{inspection-1}}
Voici les incidences annuelles en graphique:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{plot}\NormalTok{(inc_annuelle, }\DataTypeTok{type=}\StringTok{"p"}\NormalTok{, }\DataTypeTok{xlab=}\StringTok{"Année"}\NormalTok{, }\DataTypeTok{ylab=}\StringTok{"Incidence annuelle"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\includegraphics{analyse-syndrome-grippal_files/figure-latex/unnamed-chunk-19-1.pdf}
\hypertarget{identification-des-uxe9piduxe9mies-les-plus-fortes}{%
\subsubsection{Identification des épidémies les plus
fortes}\label{identification-des-uxe9piduxe9mies-les-plus-fortes}}
Une liste triée par ordre décroissant d'incidence annuelle permet de
plus facilement repérer les valeurs les plus élevées:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{head}\NormalTok{(inc_annuelle[}\KeywordTok{order}\NormalTok{(}\OperatorTok{-}\NormalTok{inc_annuelle}\OperatorTok{$}\NormalTok{incidence),])}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## annee incidence
## 4 1989 5460155
## 5 1990 5233987
## 1 1986 5100540
## 28 2013 4182265
## 25 2010 4085126
## 14 1999 3897443
\end{verbatim}
Enfin, un histogramme montre bien que les épidémies fortes, qui touchent
environ 10\% de la population française, sont assez rares: il y en eu
trois au cours des 35 dernières années.
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{hist}\NormalTok{(inc_annuelle}\OperatorTok{$}\NormalTok{incidence, }\DataTypeTok{breaks=}\DecValTok{10}\NormalTok{, }\DataTypeTok{xlab=}\StringTok{"Incidence annuelle"}\NormalTok{, }\DataTypeTok{ylab=}\StringTok{"Nb d'observations"}\NormalTok{, }\DataTypeTok{main=}\StringTok{""}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\includegraphics{analyse-syndrome-grippal_files/figure-latex/unnamed-chunk-21-1.pdf}
\end{document}
---
title: "Votre titre"
author: "Votre nom"
date: "La date du jour"
title: "Exo 2 exercice 3"
author: "Loïck Kléparski"
date: "17/02/2021"
output: html_document
---
......@@ -10,24 +10,21 @@ output: html_document
knitr::opts_chunk$set(echo = TRUE)
```
## Quelques explications
Data url web et local pour les données de la varicelle
Ceci est un document R markdown que vous pouvez aisément exporter au format HTML, PDF, et MS Word. Pour plus de détails sur R Markdown consultez <http://rmarkdown.rstudio.com>.
Lorsque vous cliquerez sur le bouton **Knit** ce document sera compilé afin de ré-exécuter le code R et d'inclure les résultats dans un document final. Comme nous vous l'avons montré dans la vidéo, on inclue du code R de la façon suivante:
```{r cars}
summary(cars)
```{r}
data_url = "https://www.sentiweb.fr/datasets/incidence-PAY-7.csv"
data_url_local = "D:/PhD/formation recherche reproductible/mooc-rr/module3/exo2/incidence-PAY-7.csv"
```
Et on peut aussi aisément inclure des figures. Par exemple:
Lecture des données en locale
```{r pressure, echo=FALSE}
plot(pressure)
```{r}
data_locale = read.csv(data_url_local, skip = 1)
```
Vous remarquerez le paramètre `echo = FALSE` qui indique que le code ne doit pas apparaître dans la version finale du document. Nous vous recommandons dans le cadre de ce MOOC de ne pas utiliser ce paramètre car l'objectif est que vos analyses de données soient parfaitement transparentes pour être reproductibles.
Comme les résultats ne sont pas stockés dans les fichiers Rmd, pour faciliter la relecture de vos analyses par d'autres personnes, vous aurez donc intérêt à générer un HTML ou un PDF et à le commiter.
Plot les
```{r}
plot(data_locale$indicator ~ data_locale$week)
```
Maintenant, à vous de jouer! Vous pouvez effacer toutes ces informations et les remplacer par votre document computationnel.
This source diff could not be displayed because it is too large. You can view the blob instead.
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