|
@@ -0,0 +1,109 @@ |
|
|
|
|
|
--- |
|
|
|
|
|
title: "Données tabulaires" |
|
|
|
|
|
author: "Maxime Wack" |
|
|
|
|
|
date: "19/11/2019" |
|
|
|
|
|
output: |
|
|
|
|
|
xaringan::moon_reader: |
|
|
|
|
|
css: ['default','css/my_style.css'] |
|
|
|
|
|
lib_dir: libs |
|
|
|
|
|
seal: false |
|
|
|
|
|
nature: |
|
|
|
|
|
ratio: '4:3' |
|
|
|
|
|
countIncrementalSlides: false |
|
|
|
|
|
self-contained: true |
|
|
|
|
|
beforeInit: "addons/macros.js" |
|
|
|
|
|
highlightLines: true |
|
|
|
|
|
pdf_document: |
|
|
|
|
|
seal: false |
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
```{r setup, include=FALSE} |
|
|
|
|
|
knitr::opts_chunk$set(echo = TRUE, fig.asp= .5) |
|
|
|
|
|
library(tidyverse) |
|
|
|
|
|
library(DT) |
|
|
|
|
|
library(knitr) |
|
|
|
|
|
|
|
|
|
|
|
options(DT.options = list(paging = F, |
|
|
|
|
|
info = F, |
|
|
|
|
|
searching = F)) |
|
|
|
|
|
|
|
|
|
|
|
datatable <- partial(datatable, rownames = F) |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
class: center, middle, title |
|
|
|
|
|
|
|
|
|
|
|
# UE Visualisation |
|
|
|
|
|
|
|
|
|
|
|
### 2019-2020 |
|
|
|
|
|
|
|
|
|
|
|
## Dr. Maxime Wack |
|
|
|
|
|
|
|
|
|
|
|
### AHU Informatique médicale |
|
|
|
|
|
#### Hôpital Européen Georges Pompidou, </br> Université de Paris |
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
# Données tabulaires |
|
|
|
|
|
|
|
|
|
|
|
.center[Chargement des données avec `read_csv`] |
|
|
|
|
|
|
|
|
|
|
|
```{r data, message = F} |
|
|
|
|
|
read_csv("lab03_data/notes.csv") -> notes |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
```{r data do, echo = F} |
|
|
|
|
|
datatable(notes) |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
# Pivot |
|
|
|
|
|
|
|
|
|
|
|
.center[Données *wide* → *long*] |
|
|
|
|
|
|
|
|
|
|
|
```{r pivot_longer} |
|
|
|
|
|
pivot_longer(notes, |
|
|
|
|
|
Alice:David, |
|
|
|
|
|
names_to = "Prénom", |
|
|
|
|
|
values_to = "Note") -> notes_long |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
```{r pivot_longer_do, echo = F} |
|
|
|
|
|
datatable(notes_long) |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
# Pivot |
|
|
|
|
|
|
|
|
|
|
|
.center[Données *long* → *wide*] |
|
|
|
|
|
|
|
|
|
|
|
```{r pivot_wider, eval = F} |
|
|
|
|
|
pivot_wider(notes_long, |
|
|
|
|
|
names_from = Prénom, |
|
|
|
|
|
values_from = Note) |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
```{r pivot_wider do, echo = F} |
|
|
|
|
|
pivot_wider(notes_long, |
|
|
|
|
|
names_from = Prénom, |
|
|
|
|
|
values_from = Note) %>% |
|
|
|
|
|
datatable |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
# Exercices |
|
|
|
|
|
|
|
|
|
|
|
Utiliser les fonctions de `pivot_*` pour exprimer le dataset `gapminder` de différentes manières. |
|
|
|
|
|
|
|
|
|
|
|
### Représenter l'intégralité sous forme clé-valeur |
|
|
|
|
|
|
|
|
|
|
|
Chaque ligne ne doit porter qu'une valeur de `lifeExp`, `gdpPercap` ou `pop`, pour chaque pays et chaque année. |
|
|
|
|
|
|
|
|
|
|
|
### Représenter un pays par ligne |
|
|
|
|
|
|
|
|
|
|
|
Une seule ligne par pays, toutes les années × indicateur doivent donner lieu à une nouvelle colonne |
|
|
|
|
|
|
|
|
|
|
|
### Reformer gapminder à partir du précédent exercice |