Skip to content

Commit

Permalink
Deploy case-study apps
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Feb 23, 2021
1 parent 8fe6901 commit aa80ca5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
33 changes: 29 additions & 4 deletions basic-case-study.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ case_study_screenshot <- function(name) {
knitr::include_graphics(png_path, dpi = screenshot_dpi())
}
case_study_deploy <- function(name) {
tmp <- dir_create(file_temp())
data <- c("injuries.tsv.gz", "population.tsv", "products.tsv")
file_copy(path("neiss", data), tmp)
file_copy(paste0("neiss/", name, ".R"), path(tmp, "app.R"))
rsconnect::deployApp(
appDir = tmp,
appName = paste0("ms-", name),
appTitle = paste0("Mastering Shiny: ", name),
server = "shinyapps.io",
forceUpdate = TRUE,
logLevel = "quiet",
launch.browser = FALSE
)
}
if (FALSE) {
case_study_deploy("narrative")
case_study_deploy("polish-tables")
case_study_deploy("prototype")
case_study_deploy("rate-vs-count")
}
```

## Introduction
Expand Down Expand Up @@ -210,7 +235,7 @@ Note that creating the `summary` reactive isn't strictly necessary here, as it's
But it's good practice to keep computing and plotting separate as it makes the flow of the app easier to understand, and will make it easier to generalise in the future.

A screenshot of the resulting app is shown in Figure \@ref(fig:prototype).
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/prototype.R> and try out a live version of the app at XYZ.
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/prototype.R> and try out a live version of the app at <https://hadley.shinyapps.io/ms-prototype/>.

```{r prototype, echo = FALSE, out.width = "100%", fig.cap="First prototype of NEISS exploration app"}
case_study_screenshot("prototype")
Expand Down Expand Up @@ -246,7 +271,7 @@ I made one other change to improve the aesthetics of the app: I forced all table
This makes the output more aesthetically pleasing because it reduces the amount of incidental variation.

A screenshot of the resulting app is shown in Figure \@ref(fig:polish-tables).
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/polish-tables.R> and try out a live version of the app at XYZ.
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/polish-tables.R> and try out a live version of the app at <https://hadley.shinyapps.io/ms-polish-tables>.

```{r polish-tables, echo = FALSE, out.width = "100%", fig.cap="The second iteration of the app improves the display by only showing the most frequent rows in the summary tables"}
case_study_screenshot("polish-tables")
Expand All @@ -269,7 +294,7 @@ Then I condition on that input when generating the plot:
```

A screenshot of the resulting app is shown in Figure \@ref(fig:rate-vs-count).
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/rate-vs-count.R> and try out a live version of the app at XYZ.
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/rate-vs-count.R> and try out a live version of the app at <https://hadley.shinyapps.io/ms-rate-vs-count>.

```{r rate-vs-count, echo = FALSE, out.width = "100%", fig.cap = "In this iteration, we give the user the ability to switch between displaying the count or the population standardised rate on the y-axis."}
case_study_screenshot("rate-vs-count")
Expand All @@ -293,7 +318,7 @@ I then use `eventReactive()` to create a reactive that only updates when the but
```

A screenshot of the resulting app is shown in Figure \@ref(fig:narrative).
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/narrative.R> and try out a live version of the app at XYZ.
You can find the source code at <https://github.com/hadley/mastering-shiny/tree/master/neiss/narrative.R> and try out a live version of the app at <https://hadley.shinyapps.io/ms-narrative>.

```{r narrative, echo = FALSE, out.width = "100%", fig.cap = "The final iteration adds the ability to pull out a random narrative from the selected rows"}
case_study_screenshot("narrative")
Expand Down
4 changes: 3 additions & 1 deletion neiss/narrative.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
library(tidyverse)
library(dplyr)
library(ggplot2)
library(forcats)
library(vroom)
library(shiny)

Expand Down
4 changes: 3 additions & 1 deletion neiss/polish-tables.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
library(tidyverse)
library(dplyr)
library(ggplot2)
library(forcats)
library(vroom)
library(shiny)

Expand Down
4 changes: 3 additions & 1 deletion neiss/prototype.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
library(tidyverse)
library(dplyr)
library(ggplot2)
library(forcats)
library(vroom)
library(shiny)

Expand Down
4 changes: 3 additions & 1 deletion neiss/rate-vs-count.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
library(tidyverse)
library(dplyr)
library(ggplot2)
library(forcats)
library(vroom)
library(shiny)

Expand Down

0 comments on commit aa80ca5

Please sign in to comment.