25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lab03-tabulaire.html 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
  3. <head>
  4. <title>Données tabulaires</title>
  5. <meta charset="utf-8" />
  6. <meta name="author" content="Maxime Wack" />
  7. <link href="libs/remark-css-0.0.1/default.css" rel="stylesheet" />
  8. <script src="libs/htmlwidgets-1.5.1/htmlwidgets.js"></script>
  9. <script src="libs/jquery-1.12.4/jquery.min.js"></script>
  10. <link href="libs/datatables-css-0.0.0/datatables-crosstalk.css" rel="stylesheet" />
  11. <script src="libs/datatables-binding-0.10/datatables.js"></script>
  12. <link href="libs/dt-core-1.10.19/css/jquery.dataTables.min.css" rel="stylesheet" />
  13. <link href="libs/dt-core-1.10.19/css/jquery.dataTables.extra.css" rel="stylesheet" />
  14. <script src="libs/dt-core-1.10.19/js/jquery.dataTables.min.js"></script>
  15. <link href="libs/crosstalk-1.0.0/css/crosstalk.css" rel="stylesheet" />
  16. <script src="libs/crosstalk-1.0.0/js/crosstalk.min.js"></script>
  17. <link rel="stylesheet" href="css/my_style.css" type="text/css" />
  18. </head>
  19. <body>
  20. <textarea id="source">
  21. class: center, middle, title
  22. # UE Visualisation
  23. ### 2019-2020
  24. ## Dr. Maxime Wack
  25. ### AHU Informatique médicale
  26. #### Hôpital Européen Georges Pompidou, &lt;/br&gt; Université de Paris
  27. ---
  28. # Données tabulaires
  29. .center[Chargement des données avec `read_csv`]
  30. ```r
  31. read_csv("lab03_data/notes.csv") -&gt; notes
  32. ```
  33. <div id="htmlwidget-a9f909b507366e2763fd" style="width:100%;height:auto;" class="datatables html-widget"></div>
  34. <script type="application/json" data-for="htmlwidget-a9f909b507366e2763fd">{"x":{"filter":"none","data":[["1/1/2019","1/15/2019","2/1/2019","2/15/2019","3/1/2019","3/15/2019","4/1/2019","4/15/2019","5/1/2019","5/15/2019"],[14,16,15,17,14,15,13,15,16,17],[10,11,11,10,15,13,12,12,13,11],[18,19,18,19,19,20,19,19,17,18],[9,10,12,11,14,13,14,15,14,15]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th>Date<\/th>\n <th>Alice<\/th>\n <th>Bob<\/th>\n <th>Claire<\/th>\n <th>David<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"paging":false,"info":false,"searching":false,"columnDefs":[{"className":"dt-right","targets":[1,2,3,4]}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
  35. ---
  36. # Pivot
  37. .center[Données *wide* → *long*]
  38. ```r
  39. pivot_longer(notes,
  40. Alice:David,
  41. names_to = "Prénom",
  42. values_to = "Note") -&gt; notes_long
  43. ```
  44. <div id="htmlwidget-744a3944844d231f7996" style="width:100%;height:auto;" class="datatables html-widget"></div>
  45. <script type="application/json" data-for="htmlwidget-744a3944844d231f7996">{"x":{"filter":"none","data":[["1/1/2019","1/1/2019","1/1/2019","1/1/2019","1/15/2019","1/15/2019","1/15/2019","1/15/2019","2/1/2019","2/1/2019","2/1/2019","2/1/2019","2/15/2019","2/15/2019","2/15/2019","2/15/2019","3/1/2019","3/1/2019","3/1/2019","3/1/2019","3/15/2019","3/15/2019","3/15/2019","3/15/2019","4/1/2019","4/1/2019","4/1/2019","4/1/2019","4/15/2019","4/15/2019","4/15/2019","4/15/2019","5/1/2019","5/1/2019","5/1/2019","5/1/2019","5/15/2019","5/15/2019","5/15/2019","5/15/2019"],["Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David","Alice","Bob","Claire","David"],[14,10,18,9,16,11,19,10,15,11,18,12,17,10,19,11,14,15,19,14,15,13,20,13,13,12,19,14,15,12,19,15,16,13,17,14,17,11,18,15]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th>Date<\/th>\n <th>Prénom<\/th>\n <th>Note<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"paging":false,"info":false,"searching":false,"columnDefs":[{"className":"dt-right","targets":2}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
  46. ---
  47. # Pivot
  48. .center[Données *long* → *wide*]
  49. ```r
  50. pivot_wider(notes_long,
  51. names_from = Prénom,
  52. values_from = Note)
  53. ```
  54. <div id="htmlwidget-206da931c15e14bd710f" style="width:100%;height:auto;" class="datatables html-widget"></div>
  55. <script type="application/json" data-for="htmlwidget-206da931c15e14bd710f">{"x":{"filter":"none","data":[["1/1/2019","1/15/2019","2/1/2019","2/15/2019","3/1/2019","3/15/2019","4/1/2019","4/15/2019","5/1/2019","5/15/2019"],[14,16,15,17,14,15,13,15,16,17],[10,11,11,10,15,13,12,12,13,11],[18,19,18,19,19,20,19,19,17,18],[9,10,12,11,14,13,14,15,14,15]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th>Date<\/th>\n <th>Alice<\/th>\n <th>Bob<\/th>\n <th>Claire<\/th>\n <th>David<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"paging":false,"info":false,"searching":false,"columnDefs":[{"className":"dt-right","targets":[1,2,3,4]}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
  56. ---
  57. # Exercices
  58. Utiliser les fonctions de `pivot_*` pour exprimer le dataset `gapminder` de différentes manières.
  59. ### Représenter l'intégralité sous forme clé-valeur
  60. Chaque ligne ne doit porter qu'une valeur de `lifeExp`, `gdpPercap` ou `pop`, pour chaque pays et chaque année.
  61. ### Représenter un pays par ligne
  62. Une seule ligne par pays, toutes les années × indicateur doivent donner lieu à une nouvelle colonne
  63. ### Reformer gapminder à partir du précédent exercice
  64. </textarea>
  65. <style data-target="print-only">@media screen {.remark-slide-container{display:block;}.remark-slide-scaler{box-shadow:none;}}</style>
  66. <script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
  67. <script src="addons/macros.js"></script>
  68. <script>var slideshow = remark.create({
  69. "ratio": "4:3",
  70. "countIncrementalSlides": false,
  71. "self-contained": true,
  72. "highlightLines": true
  73. });
  74. if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
  75. window.dispatchEvent(new Event('resize'));
  76. });
  77. (function(d) {
  78. var s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
  79. if (!r) return;
  80. s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
  81. d.head.appendChild(s);
  82. })(document);
  83. (function(d) {
  84. var el = d.getElementsByClassName("remark-slides-area");
  85. if (!el) return;
  86. var slide, slides = slideshow.getSlides(), els = el[0].children;
  87. for (var i = 1; i < slides.length; i++) {
  88. slide = slides[i];
  89. if (slide.properties.continued === "true" || slide.properties.count === "false") {
  90. els[i - 1].className += ' has-continuation';
  91. }
  92. }
  93. var s = d.createElement("style");
  94. s.type = "text/css"; s.innerHTML = "@media print { .has-continuation { display: none; } }";
  95. d.head.appendChild(s);
  96. })(document);
  97. // delete the temporary CSS (for displaying all slides initially) when the user
  98. // starts to view slides
  99. (function() {
  100. var deleted = false;
  101. slideshow.on('beforeShowSlide', function(slide) {
  102. if (deleted) return;
  103. var sheets = document.styleSheets, node;
  104. for (var i = 0; i < sheets.length; i++) {
  105. node = sheets[i].ownerNode;
  106. if (node.dataset["target"] !== "print-only") continue;
  107. node.parentNode.removeChild(node);
  108. }
  109. deleted = true;
  110. });
  111. })();
  112. // adds .remark-code-has-line-highlighted class to <pre> parent elements
  113. // of code chunks containing highlighted lines with class .remark-code-line-highlighted
  114. (function(d) {
  115. const hlines = d.querySelectorAll('.remark-code-line-highlighted');
  116. const preParents = [];
  117. const findPreParent = function(line, p = 0) {
  118. if (p > 1) return null; // traverse up no further than grandparent
  119. const el = line.parentElement;
  120. return el.tagName === "PRE" ? el : findPreParent(el, ++p);
  121. };
  122. for (let line of hlines) {
  123. let pre = findPreParent(line);
  124. if (pre && !preParents.includes(pre)) preParents.push(pre);
  125. }
  126. preParents.forEach(p => p.classList.add("remark-code-has-line-highlighted"));
  127. })(document);</script>
  128. <script>
  129. (function() {
  130. var links = document.getElementsByTagName('a');
  131. for (var i = 0; i < links.length; i++) {
  132. if (/^(https?:)?\/\//.test(links[i].getAttribute('href'))) {
  133. links[i].target = '_blank';
  134. }
  135. }
  136. })();
  137. </script>
  138. <script>
  139. slideshow._releaseMath = function(el) {
  140. var i, text, code, codes = el.getElementsByTagName('code');
  141. for (i = 0; i < codes.length;) {
  142. code = codes[i];
  143. if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
  144. text = code.textContent;
  145. if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
  146. /^\$\$(.|\s)+\$\$$/.test(text) ||
  147. /^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
  148. code.outerHTML = code.innerHTML; // remove <code></code>
  149. continue;
  150. }
  151. }
  152. i++;
  153. }
  154. };
  155. slideshow._releaseMath(document);
  156. </script>
  157. <!-- dynamically load mathjax for compatibility with self-contained -->
  158. <script>
  159. (function () {
  160. var script = document.createElement('script');
  161. script.type = 'text/javascript';
  162. script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML';
  163. if (location.protocol !== 'file:' && /^https?:/.test(script.src))
  164. script.src = script.src.replace(/^https?:/, '');
  165. document.getElementsByTagName('head')[0].appendChild(script);
  166. })();
  167. </script>
  168. </body>
  169. </html>