--- title: 'Deploying to shinyapps.io' date: "09/17/2015" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{ShinyStan: Deploying to shinyapps.io} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- Create a ShinyStan app unique to your model and host it online with RStudio's ShinyApps service (shinyapps.io). Each app you deploy will have a unique url. *Note: R users who don't use RStudio's IDE can still deploy ShinyStan apps to shinyapps.io.* ## Step 1: ShinyApps account **Signup** To deploy your app to RStudio's shinyapps.io you will need a ShinyApps account. If you don't already have one you can sign up at https://www.shinyapps.io/. The only limit to the number of different ShinyStan apps you can deploy is the limit set by RStudio for the [type of ShinyApps account](https://www.shinyapps.io/#pricing) you sign up for. **Setup** When you finish signing up for your ShinyApps account there will be instructions for setting up your account on your local system using `rsconnect::setAccountInfo()` (this requires first installing the **rsconnect** package) ```r rsconnect::setAccountInfo(name, token, secret) ``` where `name` is your ShinyApps account name, and `token` and `secret` can be found from your ShinyApps account web page. ## Step 2: Use `deploy_shinystan` to deploy your app to shinyapps.io The `deploy_shinystan` function will deploy a ShinyStan app unique to your model to RStudio's ShinyApps service. For the example below assume that - `my_sso` is the shinystan object you want to use - the name you want to use for the app is `MyModel` - the username for your ShinyApps account (from Step 1) is `username`. To deploy the app use the command ```r deploy_shinystan(my_sso, appName = "MyModel", account = "username") ``` **When to specify the `account` argument** If you have multiple ShinyApps accounts configured on your local system then the `account` argument is required. If you only have a single account then you can omit `account` ```r deploy_shinystan(my_sso, appName = "MyModel") ``` **Graphical posterior predictive checks: the optional `ppcheck_data` and `ppcheck_yrep` arguments** If you have a vector of observations `y` that you want to use for ShinyStan's graphical posterior predictive checks then you can also specify the optional `ppcheck_data` argument ```r deploy_shinystan(my_sso, appName = "MyModel", ppcheck_data = y) ``` If you've specified the `ppcheck_data` argument you can also use the `ppcheck_yrep` argument to tell ShinyStan the name of the parameter/quantity in your model containing the posterior predictive simulations/replications so that it is preselected as the parameter to use for doing the graphical posterior predictive checks. This is never required because you can also set this manually while using the app, but it is helpful if you want other people to view your model online because it avoids the need to communicate to them which parameter they need to select. If this parameter/quantity containing the posterior predictive replications is named `yRep` then you would use ```r deploy_shinystan(my_sso, appName = "MyModel", ppcheck_data = y, ppcheck_yrep = "yRep") ``` If the deployment process is successful the url for your app will be printed to the console and it should open in your web browser. You can also view your app by going to https://www.shinyapps.io and logging into your account.