|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Lab 07 - Données temporelles et textuelles</title>
- <meta charset="utf-8">
- <meta name="author" content="Antoine Neuraz" />
- <link href="libs/remark-css-0.0.1/default.css" rel="stylesheet" />
- <link rel="stylesheet" href="css/my_style.css" type="text/css" />
- </head>
- <body>
- <textarea id="source">
-
-
-
-
- ## TODO
-
- #### 1. charger le dataset `us_city_populations` de la librairie `vizoR`
-
- #### 2. tracer un line chart de l'évolution de la population des villes US
-
- #### 3. Mettez en évidence les 5 plus grandes villes (hint: package gghighlight)
- [introduction gghighlight](https://cran.r-project.org/web/packages/gghighlight/vignettes/gghighlight.html)
-
- #### 4. Appliquez les principes de design de Tufte
-
- ##### 5. BONUS: affichez le nom des villes directement à la fin de la ligne
-
- #### 6. Réalisez un streamgraph des 5 plus grandes villes US (hint: package ggTimeSeries)
-
- ---
-
- ## TODO 2
-
- #### Trouver une 3e visualization pertinente pour montrer l'évolution de la population des villes US.
-
- ---
-
-
- ```r
- data("us_city_populations")
-
- n_cities = 5
-
- # top_cities <-
- # us_city_populations %>%
- # filter(Rank <= n_cities) %>%
- # select(City, State, Region) %>%
- # distinct()
- #
- # to_plot <- filter(us_city_populations, City %in% top_cities$City)
-
- #to_plot <- us_city_populations
-
- last_ranks <- us_city_populations %>%
- filter(Year == max(Year)) %>%
- mutate(last_rank = Rank) %>%
- select(City, last_rank)
-
- to_plot <- left_join(us_city_populations, last_ranks, by= 'City')
-
- right_axis <- to_plot %>%
- group_by(City) %>%
- top_n(1, Year) %>%
- ungroup() %>%
- top_n(n_cities, -last_rank)
-
- ends <- right_axis %>%
- pull(Population)
-
- labels <- right_axis %>%
- pull(City)
- ```
-
- ---
- class: full
- ![](lab7-temporal_data_files/figure-html/unnamed-chunk-2-1.png)<!-- -->
- ---
- class: full
- ![](lab7-temporal_data_files/figure-html/unnamed-chunk-3-1.png)<!-- -->
- ---
-
- ![](bar_race.gif)
- </textarea>
- <script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
- <script src="addons/macros.js"></script>
- <script>var slideshow = remark.create({
- "ratio": "4:3",
- "countIncrementalSlides": false,
- "self-contained": true
- });
- if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
- window.dispatchEvent(new Event('resize'));
- });
- (function() {
- var d = document, s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
- if (!r) return;
- s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
- d.head.appendChild(s);
- })();</script>
-
- <script>
- (function() {
- var i, text, code, codes = document.getElementsByTagName('code');
- for (i = 0; i < codes.length;) {
- code = codes[i];
- if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
- text = code.textContent;
- if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
- /^\$\$(.|\s)+\$\$$/.test(text) ||
- /^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
- code.outerHTML = code.innerHTML; // remove <code></code>
- continue;
- }
- }
- i++;
- }
- })();
- </script>
- <!-- dynamically load mathjax for compatibility with self-contained -->
- <script>
- (function () {
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML';
- if (location.protocol !== 'file:' && /^https?:/.test(script.src))
- script.src = script.src.replace(/^https?:/, '');
- document.getElementsByTagName('head')[0].appendChild(script);
- })();
- </script>
- </body>
- </html>
|