Skip to content

Commit

Permalink
Re-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Feb 23, 2021
1 parent 345371c commit 8790e5f
Show file tree
Hide file tree
Showing 75 changed files with 45 additions and 15 deletions.
Binary file modified demos/action-bookmark/bookmark-auto.rds
Binary file not shown.
Binary file modified demos/action-bookmark/bookmark-server.rds
Binary file not shown.
Binary file modified demos/action-bookmark/pendulum.rds
Binary file not shown.
Binary file modified demos/action-dynamic/dynamic-conditional.rds
Binary file not shown.
Binary file modified demos/action-dynamic/dynamic-panels.rds
Binary file not shown.
Binary file modified demos/action-dynamic/filtering-final.rds
Binary file not shown.
Binary file modified demos/action-dynamic/freeze.rds
Binary file not shown.
Binary file modified demos/action-dynamic/render-filter-1.rds
Binary file not shown.
Binary file modified demos/action-dynamic/render-filter-2.rds
Binary file not shown.
Binary file modified demos/action-dynamic/render-palette-full.rds
Binary file not shown.
Binary file modified demos/action-dynamic/render-palette.rds
Binary file not shown.
Binary file modified demos/action-dynamic/render-simple.rds
Binary file not shown.
Binary file modified demos/action-dynamic/temperature.rds
Binary file not shown.
Binary file modified demos/action-dynamic/update-basics.rds
Binary file not shown.
Binary file modified demos/action-dynamic/update-button.rds
Binary file not shown.
Binary file modified demos/action-dynamic/update-nested.rds
Binary file not shown.
Binary file modified demos/action-dynamic/update-reset.rds
Binary file not shown.
Binary file modified demos/action-dynamic/wizard.rds
Binary file not shown.
Binary file modified demos/action-graphics/brushedPoints.rds
Binary file not shown.
Binary file modified demos/action-graphics/click.rds
Binary file not shown.
Binary file modified demos/action-graphics/modifying-size.rds
Binary file not shown.
Binary file modified demos/action-graphics/nearPoints.rds
Binary file not shown.
Binary file modified demos/action-graphics/persistent.rds
Binary file not shown.
Binary file modified demos/action-graphics/puppies.rds
Binary file not shown.
Binary file modified demos/action-graphics/resize.rds
Binary file not shown.
Binary file modified demos/action-tidy/across.rds
Binary file not shown.
Binary file modified demos/action-tidy/dplyr.rds
Binary file not shown.
Binary file modified demos/action-tidy/ggplot2.rds
Binary file not shown.
Binary file modified demos/action-tidy/messed-up.rds
Binary file not shown.
Binary file modified demos/action-tidy/tidied-up.rds
Binary file not shown.
Binary file modified demos/action-tidy/user-supplied.rds
Binary file not shown.
Binary file modified demos/action-transfer/case-study.rds
Binary file not shown.
Binary file modified demos/action-transfer/download-data.rds
Binary file not shown.
Binary file modified demos/action-transfer/download-rmd.rds
Binary file not shown.
Binary file modified demos/action-transfer/download.rds
Binary file not shown.
Binary file modified demos/action-transfer/upload-validate.rds
Binary file not shown.
Binary file modified demos/action-transfer/upload.rds
Binary file not shown.
Binary file modified demos/basic-app/ex-x-times-5.rds
Binary file not shown.
Binary file modified demos/basic-app/ex-x-times-y.rds
Binary file not shown.
Binary file modified demos/basic-app/server.rds
Binary file not shown.
Binary file modified demos/basic-app/ui.rds
Binary file not shown.
Binary file modified demos/basic-reactivity/action-button.rds
Binary file not shown.
Binary file modified demos/basic-reactivity/case-study-1.rds
Binary file not shown.
Binary file modified demos/basic-reactivity/connection.rds
Binary file not shown.
Binary file modified demos/basic-reactivity/simulation-2.rds
Binary file not shown.
Binary file modified demos/basic-ui/action-css.rds
Binary file not shown.
Binary file modified demos/basic-ui/action.rds
Binary file not shown.
Binary file modified demos/basic-ui/date-slider.rds
Binary file not shown.
Binary file modified demos/basic-ui/date.rds
Binary file not shown.
Binary file modified demos/basic-ui/free-text.rds
Binary file not shown.
Binary file modified demos/basic-ui/limited-choices.rds
Binary file not shown.
Binary file modified demos/basic-ui/multi-radio.rds
Binary file not shown.
Binary file modified demos/basic-ui/numeric.rds
Binary file not shown.
Binary file modified demos/basic-ui/output-plot.rds
Binary file not shown.
Binary file modified demos/basic-ui/output-table.rds
Binary file not shown.
Binary file modified demos/basic-ui/output-text.rds
Binary file not shown.
Binary file modified demos/basic-ui/placeholder.rds
Binary file not shown.
Binary file modified demos/basic-ui/radio-icon.rds
Binary file not shown.
Binary file modified demos/basic-ui/sidebar.rds
Binary file not shown.
Binary file modified demos/basic-ui/tabset-input.rds
Binary file not shown.
Binary file modified demos/basic-ui/tabset.rds
Binary file not shown.
Binary file modified demos/basic-ui/text-vs-print.rds
Binary file not shown.
Binary file modified demos/basic-ui/theme-darkly.rds
Binary file not shown.
Binary file modified demos/basic-ui/theme-flatly.rds
Binary file not shown.
Binary file modified demos/basic-ui/theme-sandstone.rds
Binary file not shown.
Binary file modified demos/basic-ui/theme-united.rds
Binary file not shown.
Binary file modified demos/basic-ui/upload.rds
Binary file not shown.
Binary file modified demos/basic-ui/yes-no.rds
Binary file not shown.
Binary file modified demos/scaling-modules/radio-extra-ui.rds
Binary file not shown.
Binary file modified demos/scaling-modules/radio-extra.rds
Binary file not shown.
Binary file modified demos/scaling-modules/wizard-module.rds
Binary file not shown.
Binary file modified demos/scaling-modules/wizard-ui.rds
Binary file not shown.
6 changes: 3 additions & 3 deletions reactivity-escaping.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source("common.R")
Shiny's reactive programming framework is incredibly useful because it automatically determines the minimal set of computations needed to update all outputs when an input changes.
But this framework is deliberately constraining, and sometimes you need to break free to do something risky but necessary.

In this chapter you'll learn how you can combine `reactiveValues()` and `observe()` to connect the right hand side of the reactive graph back to the left hand side.
In this chapter you'll learn how you can combine `reactiveValues()` and `observe()`/`observeEvent()` to connect the right hand side of the reactive graph back to the left hand side.
These techniques are powerful because they give you manual control over parts of the graph.
But they're also dangerous because they allow your app to do unnecessary work.
Most importantly, you can now create infinite loops where your app gets stuck in a cycle of updates that never ends.
Expand Down Expand Up @@ -68,12 +68,12 @@ None of these actions change the reactive graph, so it remains as in Figure \@re
## Case studies
Next, lets take a look at a few useful cases where you might combine `reactiveValues()` and `observe()` to solve problems that are otherwise very challenging (if not impossible).
Next, lets take a look at a few useful cases where you might combine `reactiveValues()` and `observeEvent()` or `observe()` to solve problems that are otherwise very challenging (if not impossible).
These are useful templates for your own apps.
### One output modified by multiple inputs
To get started we'll tackle a very simple problem: I want a common text box that's updated by multiple events[^reactivity-escaping-1]:
To get started we'll tackle a very simple problem: I want a common text box that's updated by multiple events[^reactivity-escaping-1].
[^reactivity-escaping-1]: This is rather similar to a notification, as seen in Section \@ref(notifications).
Expand Down
Binary file added render128dc48fa5fba.rds
Binary file not shown.
54 changes: 42 additions & 12 deletions scaling-packages.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ source("common.R")
options(tibble.print_min = 6, tibble.print_max = 6)
```

If you are creating a large/long-term Shiny app, I strongly recommend that you organise your app in the same way you'd organise an R package.
If you are creating a large or long-term Shiny app, I highly recommend that you organise your app in the same way as an R package.
This means three things:

- All R code lives in an `R/` directory.

- There's a function that creates your app (i.e. calls `shinyApp()` with your UI and server)
- There's a function that creates your app (i.e. calls `shinyApp()` with your UI and server).

- A `DESCRIPTION` file exists in the root directory of the app.

Expand All @@ -24,7 +24,7 @@ But packages can also be very simple, and at their heart, the key idea of a pack
Here, I'll start by showing you how to achieve the absolute minimal compliance with the standard, and then provide a few hints as to next steps.

As you start working with apps that use the package structure, you may find that you enjoy the process and want to learn more.
I recommend [*R Packages*](https://r-pkgs.org){.uri}, and if you want to learn more about the intersection of R packages and Shiny apps, I highly recommend [*Engineering Shiny*](http://engineering-shiny.org/){.uri}, by Colin Fay, Sébastien Rochette, Vincent Guyader, Cervan Girard.
I recommend [*R Packages*](https://r-pkgs.org){.uri}, and if you want to learn more about the intersection of R packages and Shiny apps, I recommend [*Engineering Shiny*](http://engineering-shiny.org/){.uri}, by Colin Fay, Sébastien Rochette, Vincent Guyader, Cervan Girard.

```{r setup}
library(shiny)
Expand Down Expand Up @@ -91,23 +91,23 @@ As your app grows bigger, it's also worth remembering the keyboard shortcuts you
- When your cursor is on the name of function `F2` will jump to the function definition.
If you do a lot of package development, we recommend making a couple of small additions to your `.Rprofile`.
This file contains R code that's run whenever you start R, so it's a great way to customise your interactive development environment.
You can open it by running `usethis::edit_r_profile()`.
If you do a lot of package development, we recommend making a couple of small additions to your `.Rprofile`:
``` {.r}
if (interactive()) {
suppressMessages(suppressWarnings(require(devtools)))
suppressMessages(suppressWarnings(require(usethis)))
suppressMessages(suppressWarnings(require(testthat)))
}
```

This file contains R code that's run whenever you start R, so it's a great way to customise your interactive development environment.
You can open it by running `usethis::edit_r_profile()`.

## `R CMD check`

To make a "real" package, you can use `Cmd/Ctrl + Shift + E`.
That calls `devtools::check()` which in turn calls `R CMD check`.
This is R's tool for checking compliance to the package standard.
Getting `R CMD check` to pass is quite a lot of work and there's little pay off in the short term.
To make a "real" package use use `Cmd/Ctrl + Shift + E` to repeatedly call `R CMD check` and fix all the problems that you find.
`R CMD check` is R's tool for checking compliance to the package standard.
It's a lot of work to get it to pass and there's little pay off in the short term.
But in the long-term this will protect you against a number of potential problems, and because it ensures your app adheres to standards that R developers are familiar with, it makes it easier for others to contribute to your app.

I don't recommend that you do this the first time, the second time, or even the third time you try out the package structure.
Expand All @@ -128,14 +128,16 @@ Then use the following hints to get `R CMD check` passing cleanly:
(Using `@import` is not generally consider best practice, but it makes sense here).

- Pick a license and then use the appropriate `use_license_` function to put it in the right place.
As of usethis 2.0.0, you can also pick a proprietary license with `usethis::use_proprietary_license()`.
If you code is proprietary, not open source, use `usethis::use_proprietary_license()`.
See <https://r-pkgs.org/license.html> for more details.

- Add `app.R` to `.Rbuildignore` with `usethis::use_build_ignore("app.R")` or similar.

- If your app contains small reference datasets, put them in `data` or `inst/extdata`.

The advantage of `data/` is that it's stored in `.rda` format, which is faster to load, and is loaded lazily so if it's not used by the app, it's not loaded in memory.
You can create `data/` files in the correct format with `usethis::use_data()`.
Learn more in <https://r-pkgs.org/data.html>.

Alternatively, you can put raw data in `inst/ext` and load it with `read.csv(system.file("exdata", "mydata.csv", package = "myApp"))` or similar.

Expand All @@ -150,3 +152,31 @@ Then use the following hints to get `R CMD check` passing cleanly:
[^scaling-packages-1]: The distinction between Imports and Suggests is not generally important for app packages.
If you do want to make a distinction, the most useful is to use Imports for packages that need to be present on the deployment machine (in order for the app to work) and Suggests for packages that need to be present on the development machine (in order to develop the app).
## The whole game
Let's apply all these steps to turn a simple app into a package:
```{r}
library(shiny)
load_file <- function(name, path) {
ext <- tools::file_ext(name)
switch(ext,
csv = vroom::vroom(path, delim = ","),
tsv = vroom::vroom(path, delim = "\t"),
validate("Invalid file; Please upload a .csv or .tsv file")
)
}
# Needs function
# Needs dataset
ui <- fluidPage(
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
```

0 comments on commit 8790e5f

Please sign in to comment.