class: center, middle, inverse, title-slide .title[ # Data Analysis and Visualization ] .subtitle[ ## Chapter 3. Exploratory Data Analysis in R ] .author[ ### Iñaki Úcar ] .institute[ ### Department of Statistics | uc3m-Santander Big Data Institute ] .institute[ ### Bachelor in Data and Business Analytics ] .date[ ###
Licensed under Creative Commons Attribution
CC BY 4.0
Last generated: 2025-09-06
] --- class: base24 # Catalog of Graphs and Applications .footnote[Based on [The R Graph Gallery](https://r-graph-gallery.com/)] .pull-left[ - .distribution[[Distribution](ch3_1.html#3)].icons[      ] - .correlation[[Correlation](ch3_2.html#3)].icons[       ] - .ranking[[Ranking](ch3_3.html#3)].icons[       ] - .part[[Part of a Whole](ch3_4.html#3)].icons[       ] ] .pull-right[ - .evolution[[Evolution](ch3_5.html#3)].icons[      ] - .map[[Map](ch3_6.html#3)].icons[       ] - .flow[[Flow](ch3_7.html#3)].icons[      ] - .other[[Other resources](ch3_8.html#3)].icons[     ] ] --- class: evolution # Evolution .footnote[[< Contents](#2)] [](https://r-graph-gallery.com/line-plot.html) [](https://r-graph-gallery.com/area-chart.html) [](https://r-graph-gallery.com/stacked-area-graph.html) [](https://r-graph-gallery.com/streamgraph.html) [](https://r-graph-gallery.com/time-series.html) .bottom[Line plot] .bottom[Area] .bottom[Stacked area] .bottom[Stream chart] .bottom[Time series] <br> .black.font120[ - Visualization of the **evolution** of series - Individual data points are not important - When `x` is time -> **time series** ] --- class: evolution # Evolution  Line plot .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> filter(genre == "Action") |> ggplot() + aes(year, box_office) + * geom_line() ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/line-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Area .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> filter(genre == "Action") |> ggplot() + aes(year, box_office) + * geom_area() ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/area-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Time series .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> * mutate(date = as.Date( * ISOdate(year, 1, 1))) |> filter(genre == "Action") |> ggplot() + * aes(date, box_office) + geom_line() ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/line-time-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Time series .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> mutate(date = as.Date( ISOdate(year, 1, 1))) |> ggplot() + aes(date, box_office) + * geom_line(aes(color=genre)) ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/line-color-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Time series .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> mutate(date = as.Date( ISOdate(year, 1, 1))) |> * mutate(genre = forcats::fct_reorder2( * genre, year, box_office)) |> ggplot() + aes(date, box_office) + geom_line(aes(color=genre)) ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/line-order-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Time series .footnote[[< Contents](#2)] .pull-left-mod[ ``` r df <- ggstream::blockbusters |> mutate(date = as.Date( ISOdate(year, 1, 1))) text <- df |> group_by(genre) |> * slice(n()) ggplot(df) + aes(date, box_office, * color=genre) + geom_line() + * geom_text(aes(label=genre), text, hjust=-0.1) + * expand_limits( x=as.Date("2024-01-01")) + theme(legend.position="none") ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/line-annotation-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Stacked area .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> mutate(date = as.Date( ISOdate(year, 1, 1))) |> ggplot() + aes(date, box_office) + * geom_area(aes(fill=genre)) ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/area-fill-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Streamchart .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> mutate(date = as.Date( ISOdate(year, 1, 1))) |> ggplot() + aes(date, box_office) + * ggstream::geom_stream( aes(fill=genre), * type="ridge") ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/stream-ridge-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Streamchart .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> mutate(date = as.Date( ISOdate(year, 1, 1))) |> ggplot() + aes(date, box_office) + ggstream::geom_stream( aes(fill=genre), * type="mirror") ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/stream-mirror-1.png" style="display: block; margin: auto;" /> ] --- class: evolution # Evolution  Streamchart .footnote[[< Contents](#2)] .pull-left-mod[ ``` r ggstream::blockbusters |> mutate(date = as.Date( ISOdate(year, 1, 1))) |> ggplot() + aes(date, box_office) + ggstream::geom_stream( aes(fill=genre), * type="proportional") ``` ] .pull-right-mod[ <img src="ch3_files/figure-html/stream-proportional-1.png" style="display: block; margin: auto;" /> ]