```
# install.packages('pacman')
library(pacman)
p_load('gt',
'gtsummary', 'modelsummary', 'gifski', 'png', 'datasauRus',
'ggplot2', 'gganimate', 'dplyr', 'reshape2', 'eurostat',
'knitr', 'extrafont', 'ggtext', 'ggrepel', 'patchwork',
'ggpmisc', 'gtrendsR', 'ggnewscale', 'tidyverse',
'lubridate', 'broom', 'marginaleffects', 'ggmap',
'rnaturalearth', 'sf', 'plotly', 'shiny', 'lemon',
'kableExtra', 'randomNames', 'stargazer', 'gapminder',
'htmlwidgets', 'sparkline')
```

# About

This website serves as slides and script for the GESIS workshop ** Applied Data Visualization**, for the seminar

**(Universität Freiburg) as well as for workshops in other, shorter formats taught by Paul C. Bauer .**

*Datenvisualisiserung für Politikwissenschafter*^{1}Original material is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license. Where I draw on other authors material (I do so extensively) other licenses may apply. Please note the references in the syllabus as well as the citations and links in the script. For potential future versions of this material see www.paulcbauer.de. If you have feedback or discover errors/dead links please let me know (mail@paulcbauer.de). And make sure to install all the necessary packages before you use the script.

- Current version of website can be found at https://bookdown.org/paulcbauer/applied-data-visualization/.
- Interested in a data visualization workshop at your institution/company? Please contact me at
**mail@paulcbauer.de**.

# 1 Versions: Workshops & Seminars

**Seminar at University of Freiburg (18h teaching hours in total)**: Siehe Syllabus.**Gesis: 4 days (18h in total)**: This GESIS version lasts 18 ours across 4 days and cover almost all of the content in the script. Different foki are set depending on participants demands.- Hours: 10:00 - 12:00 and 13:00 - 15:30
**Dates**,**Contact**and**Outline:**See syllabus (received link via email).

**Wuppertal: 1 day (7h in total)**- 2 Introduction; 3 Quality of Graphs (Skip 4, 5); 4 Grammar of graphics; 5 Visualizing descriptive statistics (1-4); 6 Visualizing statistical models (1-5); 9 Interactive data visualization (intro, theory, plotly)
- Hours: 9:00 - 12:00 and 13:00 - 17:00 (1 hour lunch break and shorter breaks inbetween)

**Bremen: 1 day (7h in total)**- 2 Introduction (skip 6/8); 3 Quality of Graphs (skip 5); 13 Academic posters, 4 Grammar of graphics; 5 Visualizing descriptive statistics (1-4); 6 Visualizing statistical models (1-4); 12 Visualizing text data; 9 Interactive data visualization (maybe Shiny/Plotly)
- Hours: 9:00 - 12:00 and 13:00 - 17:00 (1 hour lunch break and shorter breaks inbetween)

**I hope you are fine with the schedule?**- Whenever you need a break let me know!

# 2 Instructor: About me

- Instructor at University of Freiburg (Department of politics), Postdoc at LMU Munich (statistics department, Frauke Kreuter), External fellow at Mannheim Centre for European Social Research
- Previously
- PhD in Social Sciences at the University of Bern
- research/postdoctoral fellow at the Mannheim Centre for European Social Research, the European University Institute (Florence, Italy)

- My research (Google Scholar)
**Substantive**: Political sociology (Trust, polarization, social media, fake news)**Methods/data**: Causal inference, experiments, text data, data visualization, machine learning, big data (Google trends, Twitter)

- Interest in visualization:
- Triggered by Richard Traunmüller
^{2}among others - Have been to a workshop by Edward Tufte (together with many others ;-))
- Started R around 2009, Moved from base R to Ggplot2 around 2017/2018 (through Plotly)

- Triggered by Richard Traunmüller
- Gesis workshops: Applied Data Visualization, Interactive Data Analysis with Shiny, Applied Machine Learning (with R)
- Contact:
`mail@paulcbauer.de`

; www.paulcbauer.de; Twitter; Github

# 3 Your turn

- Let’s check our the survey results…

- Name?
- Country? (Affiliation?)
- Discipline

# 4 Script & material

**Literature**: See syllabus.**Website/script**: https://bookdown.org/paul/applied-data-visualization/- Find it: Google “applied data visualization paul”
- Document = slides + script (Zoom in/out with
`STRG + mousewheel`

) **Code**: can all be found in the script**Data**: can usually be downloaded over links in the script. If not we’ll share the files.- Full screen: F11
**Navigation**: TOCs on left and right- Search document (upper left)
- Document generated with quarto

**Motivation**: Have a go-to script for participants (and ourselves!)**Content**: Mixture of theory, lab sessions, exercises and pure code examples for discussion

# 5 Online vs. offline

- Negative
- Screen fatigue
- I can’t run around to check your code
- Less engaging, less social
- Voice
- Screen sharing…
- Less screen space than classroom

- Positive
- We see the graphs where they are mostly consumed ;-) (on a screen)
- Remember: “How is your graph consumed (smartphone)?”

- Participation from everywhere

- We see the graphs where they are mostly consumed ;-) (on a screen)
- Rule: Please keep your camera online!
- Distracting animals/children/partners are a welcome distraction!
- Yawning, leaving, looking bored etc. allowed!
- Use a virtual background if you like!

# 6 Strategy & Goals/Learning outcomes

- Hopefully you don’t expect too much (managing expectations!)
- Data visualization has become a profession
- Most newspaper now employ full-time data visualization staff (New York Times Graphics Department, Guardian Data)
- Famous data viz guys (Mike Bostock (formerly NYT now observable), Gregor Aisch, …many others)
- Some of these graphics involve advanced programming skills that we don’t have/learn (JavaScript etc.)

- Learn some fundamental principles of (data) visualization
- Theory of Data Graphics (Tufte)
- Spotting bad and good graphs
- Grammar of graphics (Cleveland, Wickham) & Ggplot

- Learn how to visualize in R
- Making better graphs (for your publications/reports)
- Learn different useful graphs for exploration & presentation
- Explore simple descriptive graphs and more complicated graphs of statistical models (e.g., coefficient plots)

- Make first steps in interactive visualization (exploration!)

**Good visualizations/graphs take time to create!**

# 7 Software we will use

- What software will we use?
- Open-source software!
- Q: What speaks for open-source software?

- R (only viable competitor is Python)
^{3}- Script/exercise were built using R version 4.3.2 (2023-10-31 ucrt).
- You can switch R versions in Rstudio.
- Install the necessary packages using the code below.

- Ggplot2
^{4} - Plotly
^{5} - Shiny: See other workshop
- Note: Ideally cite the software you use in your research especially when it is open-source (see
`citation("ggplot2")`

)

# 8 Structure (1)

- How to structure a dataviz workshop/seminar?!
- Hard classify graphs/data visualizations
- Description vs. explanation
- Exploration vs. presentation

- From data to viz
- Decision tree: Choose according to data type
- Choose according to category, e.g., distribution vs. correlation vs. ranking etc.
- BUT: who can read which graphs? (later!)

- Awareness of different approaches → creativity/ideas
- …the more graphs you have seen the better!
- …go through different great examples.

# 9 Structure (2)

- Distinctions are only so helpful… same graph can be used for exploration, description, explanation etc.
- Rationale: What do we need in every-day work?
- Grasp quality of graphs
- Understand underlying logic: Research question → Data → Graph
- Use graphs to describe data (simple summaries) and to visualize results of statistical models (t-tests, regressions etc.)
- What is your story?

- Structure of this workshop: See syllabus and TOC

# 10 Helpful resources

- https://www.r-graph-gallery.com/
- Classification: Distribution; Correlation; Ranking; Part of whole; Evolution; Map; Flow

- https://www.data-to-viz.com/
- Presenting the choice of graph as a decision tree
- A collection of dataviz caveats (what to avoid!)

- https://shiny.rstudio.com/gallery/
- Gallery of shiny apps (most visualize data)

- A Compendium of Clean Graphs in R (base R)
- Michael Friendly’s website
- flowingdata.com
- R cheat sheets
- 1 dataset 100 visualizations
- Competitions (a few for inspiration…)

## Footnotes

The first iteration of the workshop was taught in May 2020.↩︎

Check out some of Richard’s cool base R graphs from a recent workshop.↩︎

Creators: Core contributors and thousands of package authors.↩︎

Creators: https://github.com/tidyverse/ggplot2↩︎

Creators: https://github.com/plotly/plotly.js; https://github.com/ropensci/plotly↩︎