This repository contains the files used in an Introduction to Shiny reading and conference class I will teach in Fall 2019 (2019-09-30 to 2019-12-04). The class meets for a total of eight 2-hour sessions, with the last session reserved for students to show off their own apps.
Materials for class session are in separate folders for each meeting. These contain app templates that were the basis for interactive coding, handouts, and pictures of apps for students to recreate.
Apps with the code we worked on interactively together are in a folder named "interactive_exercises", mostly to help me remember what I wanted to cover. Apps that students were to recreate on their own are stored in "activity_solutions".
Here is the basic outline of what I will cover:
- Introduction
- Student introductions
- Syllabus with basic topics, final project, participation
- Materials for each class
- Structure of an app
- Go through example apps 01_hello, 03_reactivity, 04_mpg, 06_tabsets, and 10_download with runExample() (handout 1)
- Create first app: interactive coding
- Set working directory
- Make folder for app in that directory
- Copy code from "01_hello" into new script
- Save that script as app.R into app folder
- runApp() function or Run App button
- In class activity: students make minor changes to app code (change title, max slider #, plot line color)
- Build a basic app
- Start with minimal app template
- Add reactive input, reactive function, reactive output (histogram example): interactive coding
- Continue basic app as needed
- Reactive inputs (control widgets) (handout 2)
- Start with minimal app template
- Explore numericInput(), helpTextInput(), sliderInput(), selectInput(): interactive coding
- Run app "all_input_functions" to see all input functions
- In class activity: students recreate app shown in image “shiny_class_2_recreate_app.PNG”
- Sharing an app (if time allows)
- Run code in R from online or GitHub
- https://www.shinyapps.io
- Shiny server
- Render*() functions and reactive outputs (handout 3)
- Start with histogram app template we made in first week
- Render functions (renderPlot(), renderPrint(), renderText(), renderTable() ): interactive coding
- In class activity: students recreate app shown in image “shiny_class_3_recreate_app.PNG”
- Reading data into app
- Data within app folder: interactive coding
- Sharing an app (if time allows and haven't covered yet)
- Run code in R from online or GitHub
- https://www.shinyapps.io
- Shiny server
- Sharing an app (if haven't covered yet)
- Run code in R from online or GitHub
- https://www.shinyapps.io
- Shiny server
- Sidebar layout (titlePanel(), sidebarPanel() ): interactive coding
- HTML tags to control user interface (handout 4)
- Demonstrate tags (p(), em(), h1(), h2(), img() ): interactive coding
- Run “html_tags_example” app to show more HTML tags
- In class activity: students recreate app shown in image “shiny_class_4_recreate_app.PNG”
- Grid layout (fluidRow(), column() ): interactive coding
- In class activity: students recreate app shown in image “shiny_class_5_recreate_app.PNG”
- The reactive() function to build dataset for use in render*() functions: interactive coding
- In class activity: fix errors in five example apps
- Add interactivity to a scatterplot: interactive coding
- Can put source code in app folder
- Read in data from app folder
- Add click/hover/brush to plotOutput()
- Make tables in server(), add tableOutput() to UI
- As time allows, show adding an “All” option to selectInput() and a conditional in reactive()
- In class activity: add second variable to app to recreate “shiny_class_7_recreate_app.PNG”
- Action buttons to delay reaction: interactive coding
- Replace reactive() with eventReactive()
- Mention observeReactive() and reactiveValues()
- More built-in panel layouts (handout 5)
- Focus on tabs, show example "06_tabsets"
- Show navlistPanel example: https://shiny.rstudio.com/gallery/navlistpanel-example.html