Tuesday, 23.07 | |
10:00-11:00 | Welcome and introduction |
11:00-11:15 | Coffee break |
11:15-12:00 | Your (first) Shiny app |
12:00-13:00 | Lunch break |
13:00-14:15 | The front end: Designing the user interface |
14:15-14:30 | Coffee break |
14:30-16:00 | Tutorials for the UI |
Wednesday, 24.07. | |
10:00-11:00 | Introduction to reactive programming |
11:00-11:15 | Coffee break |
11:15-12:00 | Tutorials for reactive programming |
12:00-13:00 | Lunch break |
13:00-14:15 | Advanced reactive programming |
14:15-14:30 | Coffee break |
14:30-16:00 | Tutorials for reactive programming |
Thursday, 25.07 | |
10:00-11:00 | Visualization with ggplot2 and Shiny |
11:00-11:15 | Coffee break |
11:15-12:00 | Tutorials for visualization |
12:00-13:00 | Lunch break |
13:00-14:15 | Testing and deployment |
14:15-14:30 | Coffee break |
14:30-16:00 | Tutorials for deployment |
Friday, 26.07. | |
10:00-11:00 | Good practices when building your own app |
11:00-11:15 | Coffee break |
11:15-12:00 | Build your own app: Design and UI |
12:00-13:00 | Lunch break |
13:00-14:15 | Build your own app: Construct the reactive graph |
14:15-14:30 | Coffee break |
14:30-15:30 | Build your own app: Strengthen & deploy |
15:30-16:00 | Exhibit: Show off your new Shiny app |
About this workshop
This document serves as slides and script for the workshop Interactive Data Analysis with Shiny taught by Paul C. Bauer and Jonas Lieth. Original material is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license. Where we draw on other authors material other licenses may apply (see references in the syllabus as well as the citations and links in the script). For potential future versions of this material see the github repository. If you have feedback or discover errors/dead links please let us know via email (mail@paulcbauer.de/Jonas.Lieth@gesis.org) or by submitting an issue on github. And make sure to install all the necessary packages before you use the script.
1 About us (Paul & Jonas)
- Paul
- Instructor at University of Freiburg (Department of politics), Postdoc at LMU Munich (statistics department, Frauke Kreuter), External fellow at MZES
- Previously: PhD at the University of Bern; research/postdoctoral fellow at the MZES, the EUI (Florence, Italy)
- My research (Google Scholar, Github)
- Substantive: Political sociology & comparative politics (Trust, polarization, social media, fake news)
- Methods/data: Causal inference, experiments, text data, data visualization, machine learning, big data (Google trends, Twitter)
- Jonas
2 Your turn
- Let’s check our the survey results…
- Name?
- Affiliation? Country?
- What do you want to use Shiny for? (or research questions?)
3 Contact & Outline & Dates
- Important: 2nd time we teach workshop/material
- Course outline/content/dates: (see toc on the left)
4 Script & material
- Literature: See syllabus.
- Website/script: https://paulcbauer.github.io/shiny_workshop/
- Find it: Google “shiny paul jonas”
- 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 or from github (e.e., see here for the data). 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 Strategy & Goals
Strategy: From the simple to the complex, slowly building up a complex Shiny app that includes various aspects (tabulate data, modelling and descriptive graphs, mapping)
Goals: By the end of the course participants will:
- know what the structure of a Shiny application looks like
- understand the basics of reactive programming for interactive data analysis and visualization
- be comfortable to use R Shiny to build their own interactive applications
- have learned about different ways to deploy their Shiny application
6 Online vs. offline
- Negative
- Screen fatigue
- Can’t run around to check your code
- Less engaging, less social
- Voice
- Screen sharing &less screen space than classroom
- Positive
- We see the Shiny app how its mostly consumed ;-) (on a screen)
- Remember: “How is your Shiny app consumed (smartphone)?”
- Participation from everywhere
- We see the Shiny app how its mostly consumed ;-) (on a screen)
- Rule(s): Please keep your camera online if possible!
- Distracting animals/children/partners are a welcome distraction!
- Yawning, leaving, looking bored etc. allowed!
- Use a virtual background if you like!
- Any questions are welcome!
7 Recommended readings
- Important: Our workshop does not require any prior reading.
- However, our schedule is primarily based on two textbooks which we generally recommend for further reading (see references on website):
- Wickham (2021): Mastering Shiny: Build Interactive Apps, Reports, and Dashboards Powered by R. Accessible online at: https://mastering-shiny.org/.
- Fay, Colin, Rochette, Sébastien, Guyader, Vincent, and Girard, Cervan (2022): Engineering Production-Grade Shiny Apps. Accessible online at: https://engineering-shiny.org/.
8 Software we will use
- Open-source software! (Q: Why?)
- R (R Core Team 2023)1
- only viable competitor is Python
- Install the necessary packages using the code below.
# install.packages("pacman")
pacman::p_load(c(
apexcharter,
broom,
datasauRus,
gganimate,
gifski,
gt,
gtsummary,
haven,
highcharter,
htmltools,
httpuv,
kableExtra,
leaflet,
listviewer,
modelsummary,
plotly,
png,
profvis,
reactlog,
rsconnect,
sf,
shiny,
shinylive,
tidyverse
))
- Shiny (Chang et al. 2022; Wickham 2021)
- ggplot22 (Wickham 2016)
- plotly3 (Sievert 2020)
- Note: Ideally cite the software you use in your research especially when it is open-source (e.g., run
citation("ggplot2")
)
9 Helpful resources
References
Footnotes
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↩︎