WebApps 6502
Session 1.1–Introduction to R Shiny
Getting to Know Each Other 🗣
- Name and background
- Reasons for taking the course
- Experience with programming
- Experience with R and Shiny
- What you hope to learn
Today’s Schedule
- 9:00 - 10:20: Introduction to R Shiny
- 10:20 - 10:40: Break ☕
- 10:40 - 12:00: Shiny Basics
- 12:00 - 1:00: Lunch 🍕🥤
- 1:00 - 2:20: Scatter Plot App, Part 1
- 2:20 - 2:40: Break ☕
- 2:40 - 4:00: Scatter Plot App, Part 2
Learning Objectives
After this workshop, you will know:
- What Shiny is and how it works
- The elements of a Shiny app including a user interface and server
- How to create a simple Shiny app
- How to deploy a Shiny app
What is Shiny?
- Shiny is an R package developed by Posit that makes it easy to build interactive web apps straight from R
- No HTML, CSS, or JavaScript required
- Shiny apps can be hosted on the web or run locally
- Makes it easy to explore your data and share your analysis
What You Can Do with Shiny
- Data Exploration: Utilize interactive widgets to filter and sort data dynamically
- Basic Visualizations: Create real-time, interactive graphs and charts from datasets
- Advanced Analytics: Integrate R’s robust statistical and machine learning capabilities for in-depth analysis
- Interactive Reports: Build dynamic reports that update based on user input or live data
- Production-Grade Dashboards: Develop complex, multi-page dashboards with user authentication and data streaming
Flavors of Shiny
- R Shiny: The original framework, allowing R users to build interactive web applications directly within R
- Shiny for Python: Extends Shiny’s capabilities to Python, enabling Python users to create Shiny applications using Python code
- Shiny Live: Enables you to run apps off the user’s browser rather than having to deploy them to a server (only available in Python right now)
- Shiny Express: A simplified version of Shiny for Python aimed at rapid development and deployment of applications with less coding and configuration required
- Quarto Dashboards: Not a Shiny app per se, but can connected to a Shiny server for increased interactivity
User Demos
- Have a look at the Shiny gallery
- Pick an app that you like?
- One thing you would like to learn from that app?
- One thing that you would improve
- Discuss with a neighbor
Feature Demos
- Now let’s look at feature demos
- What widgets, layouts, or features are you interested in?
- How would you use them in your own apps?
Professional Apps
- Here is a selection of modern, professional Shiny Apps
- These are mainly for inspiration, but try to find the code on GitHub and see how much you can understand
Getting Started with Shiny
- Open RStudio
- Start a folder for the workshop
- Install the
shiny
package (if not installed already)
- Create a new Shiny app
- (File > New File > Shiny Web App)
- Run the Geyser App
- Try opening it in a browser
Challenge
- Look at the
faithful
dataset in R (hint: ?faithful
)
- Create a Shiny app that displays a histogram of the
eruptions
column
- Change the labels accordingly
- What kind of distribution do you see?