|
| 1 | +# Deploying to shinyapps.io |
| 2 | + |
| 3 | +Create a ShinyStan app unique to your model and host it online with |
| 4 | +RStudio’s ShinyApps service (shinyapps.io). Each app you deploy will |
| 5 | +have a unique url. |
| 6 | + |
| 7 | +*Note: R users who don’t use RStudio’s IDE can still deploy ShinyStan |
| 8 | +apps to shinyapps.io.* |
| 9 | + |
| 10 | +## Step 1: ShinyApps account |
| 11 | + |
| 12 | +**Signup** |
| 13 | + |
| 14 | +To deploy your app to RStudio’s shinyapps.io you will need a ShinyApps |
| 15 | +account. If you don’t already have one you can sign up at |
| 16 | +<https://www.shinyapps.io/>. |
| 17 | + |
| 18 | +The only limit to the number of different ShinyStan apps you can deploy |
| 19 | +is the limit set by RStudio for the [type of ShinyApps |
| 20 | +account](https://www.shinyapps.io/#pricing) you sign up for. |
| 21 | + |
| 22 | +**Setup** |
| 23 | + |
| 24 | +When you finish signing up for your ShinyApps account there will be |
| 25 | +instructions for setting up your account on your local system using |
| 26 | +[`rsconnect::setAccountInfo()`](https://rstudio.github.io/rsconnect/reference/setAccountInfo.html) |
| 27 | +(this requires first installing the **rsconnect** package) |
| 28 | + |
| 29 | +``` r |
| 30 | +rsconnect::setAccountInfo(name, token, secret) |
| 31 | +``` |
| 32 | + |
| 33 | +where `name` is your ShinyApps account name, and `token` and `secret` |
| 34 | +can be found from your ShinyApps account web page. |
| 35 | + |
| 36 | +## Step 2: Use `deploy_shinystan` to deploy your app to shinyapps.io |
| 37 | + |
| 38 | +The `deploy_shinystan` function will deploy a ShinyStan app unique to |
| 39 | +your model to RStudio’s ShinyApps service. |
| 40 | + |
| 41 | +For the example below assume that |
| 42 | + |
| 43 | +- `my_sso` is the shinystan object you want to use |
| 44 | +- the name you want to use for the app is `MyModel` |
| 45 | +- the username for your ShinyApps account (from Step 1) is `username`. |
| 46 | + |
| 47 | +To deploy the app use the command |
| 48 | + |
| 49 | +``` r |
| 50 | +deploy_shinystan(my_sso, appName = "MyModel", account = "username") |
| 51 | +``` |
| 52 | + |
| 53 | +**When to specify the `account` argument** |
| 54 | + |
| 55 | +If you have multiple ShinyApps accounts configured on your local system |
| 56 | +then the `account` argument is required. If you only have a single |
| 57 | +account then you can omit `account` |
| 58 | + |
| 59 | +``` r |
| 60 | +deploy_shinystan(my_sso, appName = "MyModel") |
| 61 | +``` |
| 62 | + |
| 63 | +**Graphical posterior predictive checks: the optional `ppcheck_data` and |
| 64 | +`ppcheck_yrep` arguments** |
| 65 | + |
| 66 | +If you have a vector of observations `y` that you want to use for |
| 67 | +ShinyStan’s graphical posterior predictive checks then you can also |
| 68 | +specify the optional `ppcheck_data` argument |
| 69 | + |
| 70 | +``` r |
| 71 | +deploy_shinystan(my_sso, appName = "MyModel", |
| 72 | + ppcheck_data = y) |
| 73 | +``` |
| 74 | + |
| 75 | +If you’ve specified the `ppcheck_data` argument you can also use the |
| 76 | +`ppcheck_yrep` argument to tell ShinyStan the name of the |
| 77 | +parameter/quantity in your model containing the posterior predictive |
| 78 | +simulations/replications so that it is preselected as the parameter to |
| 79 | +use for doing the graphical posterior predictive checks. This is never |
| 80 | +required because you can also set this manually while using the app, but |
| 81 | +it is helpful if you want other people to view your model online because |
| 82 | +it avoids the need to communicate to them which parameter they need to |
| 83 | +select. If this parameter/quantity containing the posterior predictive |
| 84 | +replications is named `yRep` then you would use |
| 85 | + |
| 86 | +``` r |
| 87 | +deploy_shinystan(my_sso, appName = "MyModel", |
| 88 | + ppcheck_data = y, ppcheck_yrep = "yRep") |
| 89 | +``` |
| 90 | + |
| 91 | +If the deployment process is successful the url for your app will be |
| 92 | +printed to the console and it should open in your web browser. You can |
| 93 | +also view your app by going to <https://www.shinyapps.io> and logging |
| 94 | +into your account. |
0 commit comments