選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

133 行
3.6KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Lab 07 - Données temporelles et textuelles</title>
  5. <meta charset="utf-8">
  6. <meta name="author" content="Antoine Neuraz" />
  7. <link href="libs/remark-css-0.0.1/default.css" rel="stylesheet" />
  8. <link rel="stylesheet" href="css/my_style.css" type="text/css" />
  9. </head>
  10. <body>
  11. <textarea id="source">
  12. ## TODO
  13. #### 1. charger le dataset `us_city_populations` de la librairie `vizoR`
  14. #### 2. tracer un line chart de l'évolution de la population des villes US
  15. #### 3. Mettez en évidence les 5 plus grandes villes (hint: package gghighlight)
  16. [introduction gghighlight](https://cran.r-project.org/web/packages/gghighlight/vignettes/gghighlight.html)
  17. #### 4. Appliquez les principes de design de Tufte
  18. ##### 5. BONUS: affichez le nom des villes directement à la fin de la ligne
  19. #### 6. Réalisez un streamgraph des 5 plus grandes villes US (hint: package ggTimeSeries)
  20. ---
  21. ## TODO 2
  22. #### Trouver une 3e visualization pertinente pour montrer l'évolution de la population des villes US.
  23. ---
  24. ```r
  25. data("us_city_populations")
  26. n_cities = 5
  27. # top_cities &lt;-
  28. # us_city_populations %&gt;%
  29. # filter(Rank &lt;= n_cities) %&gt;%
  30. # select(City, State, Region) %&gt;%
  31. # distinct()
  32. #
  33. # to_plot &lt;- filter(us_city_populations, City %in% top_cities$City)
  34. #to_plot &lt;- us_city_populations
  35. last_ranks &lt;- us_city_populations %&gt;%
  36. filter(Year == max(Year)) %&gt;%
  37. mutate(last_rank = Rank) %&gt;%
  38. select(City, last_rank)
  39. to_plot &lt;- left_join(us_city_populations, last_ranks, by= 'City')
  40. right_axis &lt;- to_plot %&gt;%
  41. group_by(City) %&gt;%
  42. top_n(1, Year) %&gt;%
  43. ungroup() %&gt;%
  44. top_n(n_cities, -last_rank)
  45. ends &lt;- right_axis %&gt;%
  46. pull(Population)
  47. labels &lt;- right_axis %&gt;%
  48. pull(City)
  49. ```
  50. ---
  51. class: full
  52. ![](lab7-temporal_data_files/figure-html/unnamed-chunk-2-1.png)&lt;!-- --&gt;
  53. ---
  54. class: full
  55. ![](lab7-temporal_data_files/figure-html/unnamed-chunk-3-1.png)&lt;!-- --&gt;
  56. ---
  57. ![](bar_race.gif)
  58. </textarea>
  59. <script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
  60. <script src="addons/macros.js"></script>
  61. <script>var slideshow = remark.create({
  62. "ratio": "4:3",
  63. "countIncrementalSlides": false,
  64. "self-contained": true
  65. });
  66. if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
  67. window.dispatchEvent(new Event('resize'));
  68. });
  69. (function() {
  70. var d = document, s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
  71. if (!r) return;
  72. s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
  73. d.head.appendChild(s);
  74. })();</script>
  75. <script>
  76. (function() {
  77. var i, text, code, codes = document.getElementsByTagName('code');
  78. for (i = 0; i < codes.length;) {
  79. code = codes[i];
  80. if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
  81. text = code.textContent;
  82. if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
  83. /^\$\$(.|\s)+\$\$$/.test(text) ||
  84. /^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
  85. code.outerHTML = code.innerHTML; // remove <code></code>
  86. continue;
  87. }
  88. }
  89. i++;
  90. }
  91. })();
  92. </script>
  93. <!-- dynamically load mathjax for compatibility with self-contained -->
  94. <script>
  95. (function () {
  96. var script = document.createElement('script');
  97. script.type = 'text/javascript';
  98. script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML';
  99. if (location.protocol !== 'file:' && /^https?:/.test(script.src))
  100. script.src = script.src.replace(/^https?:/, '');
  101. document.getElementsByTagName('head')[0].appendChild(script);
  102. })();
  103. </script>
  104. </body>
  105. </html>