Skip to content

Commit aa80ca5

Browse files
committed
Deploy case-study apps
Fixes #368
1 parent 8fe6901 commit aa80ca5

5 files changed

+41
-8
lines changed

basic-case-study.Rmd

+29-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,31 @@ case_study_screenshot <- function(name) {
1919
2020
knitr::include_graphics(png_path, dpi = screenshot_dpi())
2121
}
22+
23+
case_study_deploy <- function(name) {
24+
tmp <- dir_create(file_temp())
25+
26+
data <- c("injuries.tsv.gz", "population.tsv", "products.tsv")
27+
file_copy(path("neiss", data), tmp)
28+
file_copy(paste0("neiss/", name, ".R"), path(tmp, "app.R"))
29+
30+
rsconnect::deployApp(
31+
appDir = tmp,
32+
appName = paste0("ms-", name),
33+
appTitle = paste0("Mastering Shiny: ", name),
34+
server = "shinyapps.io",
35+
forceUpdate = TRUE,
36+
logLevel = "quiet",
37+
launch.browser = FALSE
38+
)
39+
}
40+
if (FALSE) {
41+
case_study_deploy("narrative")
42+
case_study_deploy("polish-tables")
43+
case_study_deploy("prototype")
44+
case_study_deploy("rate-vs-count")
45+
}
46+
2247
```
2348

2449
## Introduction
@@ -210,7 +235,7 @@ Note that creating the `summary` reactive isn't strictly necessary here, as it's
210235
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.
211236

212237
A screenshot of the resulting app is shown in Figure \@ref(fig:prototype).
213-
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.
238+
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/>.
214239

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

248273
A screenshot of the resulting app is shown in Figure \@ref(fig:polish-tables).
249-
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.
274+
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>.
250275

251276
```{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"}
252277
case_study_screenshot("polish-tables")
@@ -269,7 +294,7 @@ Then I condition on that input when generating the plot:
269294
```
270295

271296
A screenshot of the resulting app is shown in Figure \@ref(fig:rate-vs-count).
272-
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.
297+
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>.
273298

274299
```{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."}
275300
case_study_screenshot("rate-vs-count")
@@ -293,7 +318,7 @@ I then use `eventReactive()` to create a reactive that only updates when the but
293318
```
294319

295320
A screenshot of the resulting app is shown in Figure \@ref(fig:narrative).
296-
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.
321+
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>.
297322

298323
```{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"}
299324
case_study_screenshot("narrative")

neiss/narrative.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
library(tidyverse)
1+
library(dplyr)
2+
library(ggplot2)
3+
library(forcats)
24
library(vroom)
35
library(shiny)
46

neiss/polish-tables.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
library(tidyverse)
1+
library(dplyr)
2+
library(ggplot2)
3+
library(forcats)
24
library(vroom)
35
library(shiny)
46

neiss/prototype.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
library(tidyverse)
1+
library(dplyr)
2+
library(ggplot2)
3+
library(forcats)
24
library(vroom)
35
library(shiny)
46

neiss/rate-vs-count.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
library(tidyverse)
1+
library(dplyr)
2+
library(ggplot2)
3+
library(forcats)
24
library(vroom)
35
library(shiny)
46

0 commit comments

Comments
 (0)