class: center, middle, inverse, title-slide # interactive
reporting ### 2021-11-05 --- class: middle, inverse # Welcome --- ## Announcements - Peer review of Project 2 proposals on Monday in lab - HW 5 posted --- ## Setup .midi[ ```r # load packages library(tidyverse) library(shiny) library(gt) # set default theme for ggplot2 ggplot2::theme_set(ggplot2::theme_minimal(base_size = 16)) # set default figure parameters for knitr knitr::opts_chunk$set( fig.width = 8, fig.asp = 0.618, fig.retina = 3, dpi = 300, out.width = "60%" ) # dplyr print min and max options(dplyr.print_max = 10, dplyr.print_min = 10) ``` ] --- class: middle, inverse # Shiny: High level view --- class: middle, center .center[ Every Shiny app has a webpage that the user visits, <br> and behind this webpage there is a computer that serves this webpage by running R. ] <img src="images/high-level-1.png" width="80%" /> --- class: middle, center .center[ When running your app locally, the computer serving your app is your computer. ] <img src="images/high-level-2.png" width="100%" /> --- class: middle, center .center[ When your app is deployed, the computer serving your app is a web server. ] <img src="images/high-level-3.png" width="100%" /> --- class: middle, center <img src="images/high-level-4.png" width="100%" /> --- .pull-left[ .task[ - Clone the `exercise-08` repo. - Navigate to the `goog-index` folder, and launch the app by opening the `app.R` file and clicking on *Run App*. - Close the app by clicking the stop icon - Select view mode in the drop down menu next to Run App ] ] .pull-right[ <iframe src="https://gallery.shinyapps.io/goog-trend-index/?showcase=0" width="100%" height="650px" data-external="1"></iframe> ] --- class: middle, inverse # Anatomy of a Shiny app --- ## What's in an app? .pull-left[ ```r library(shiny) ui <- fluidPage() server <- function(input, output, session) {} shinyApp(ui = ui, server = server) ``` ] .pull-right[ - **User interface** controls the layout and appearance of app - **Server function** contains instructions needed to build app ] --- ## Data: Ask a manager Source: Ask a Manager Survey via [TidyTuesday](https://github.com/rfordatascience/tidytuesday/tree/master/data/2021/2021-05-18) > This data does not reflect the general population; it reflects Ask a Manager readers who self-selected to respond, which is a very different group (as you can see just from the demographic breakdown below, which is very white and very female). Some findings [here](https://www.askamanager.org/2021/05/some-findings-from-24000-peoples-salaries.html). ```r manager <- read_csv(here::here("19-interactive-reporting", "data/survey.csv")) manager ``` ``` ## # A tibble: 26,232 × 18 ## timestamp how_old_are_you industry job_title additional_cont… annual_salary ## <chr> <chr> <chr> <chr> <chr> <dbl> ## 1 4/27/2021… 25-34 Educatio… Research… <NA> 55000 ## 2 4/27/2021… 25-34 Computin… Change &… <NA> 54600 ## 3 4/27/2021… 25-34 Accounti… Marketin… <NA> 34000 ## 4 4/27/2021… 25-34 Nonprofi… Program … <NA> 62000 ## 5 4/27/2021… 25-34 Accounti… Accounti… <NA> 60000 ## 6 4/27/2021… 25-34 Educatio… Scholarl… <NA> 62000 ## 7 4/27/2021… 25-34 Publishi… Publishi… <NA> 33000 ## 8 4/27/2021… 25-34 Educatio… Librarian High school, FT 50000 ## 9 4/27/2021… 45-54 Computin… Systems … Data developer/… 112000 ## 10 4/27/2021… 35-44 Accounti… Senior A… <NA> 45000 ## # … with 26,222 more rows, and 12 more variables: other_monetary_comp <dbl>, ## # currency <chr>, currency_other <chr>, additional_context_on_income <chr>, ## # country <chr>, state <chr>, city <chr>, ## # overall_years_of_professional_experience <chr>, ## # years_of_experience_in_field <chr>, ## # highest_level_of_education_completed <chr>, gender <chr>, race <chr> ``` --- class: middle .large[.hand[livecoding]] .task[ Go to the `exercise-08` project and code along in `manager-survey/app.R`. ]