BYUI has set up an RStudio Connect server to make it easy for data scientists to publish and share static and dynamic analysis artifacts. RStudio Connect supports publication of R Markdown documents, Shiny Apps, plots, Plumber APIs, and TensorFlow Model APIs. Note that Plumber APIs and TensorFlow Model APIs can only be published using the R console configuration.
This page provides a set of one-time setup instructions as well a publication guide. While this documentation has some information specific to our BYUI server, you can find more information about setup and publication at RStudio’s site - http://docs.rstudio.com/connect.
You will need to create an account at https://shiny.byui.edu/connect/ and then configure your local tools for publishing. We have documented the account creation and setup for the RStudio IDE as well as using the R console.
Configure push-button publication from RStudio IDE to RStudio Connect.
Publishing from the RStudio IDE. RStudio has made it very easy to publish from the RStudio IDE with the push of a button. You just need to watch for the publish icon:
This icon can be located in the following locations for each of the following content types:
After you click the publish button, you may be asked where to publish to (select ‘RStudio Connect’) and you may be asked additional information such as which account to publish from (if you have multiple endpoints to publish to, e.g. shinyapps.io – select the appropriate server), a title, etc.
If you don’t use RStudio or want to programmatically push content to RStudio Connect as part of an R script, you can configure the capability to publish through R commands.
rsconnect::connectUser(account = "byuiusername").1
Publishing from the R Terminal. If you are running R outside of RStudio (e.g. from a different GUI, a remote terminal, etc.), or if you want to automatically deploy content from inside a script, you can use R commands to publish content. Plumber APIs and TensorFlow Model APIs can only be published in this manner.
After following the setup instructions from earlier in this document, you can use the following rsconnect functions to deploy content:
deployTFModel(). The main function is
deployApp() and the others are wrappers for it for specific content types. The R help documentation for these functions will provide more information.
Here is an example of creating and publishing a plot:
# make and save a test plot library(ggplot2) qplot(1:10, 1:10) tf <- tempfile(fileext = ".pdf") ggsave(tf) # deploy the plot rsconnect::deployDoc(tf, contentCategory = "plot", appName = "test_plot", appTitle = "testing rsconnect::deployDoc()")
After you have published, a browser window will open and allow you to manage the content (or you can edit the content later on by selecting and viewing it in the RStudio Connect browser). The most important things you can set here are the following:
This command will open up a web browser to ask for your credentials. If you are in a remote R session through SSH, you will need to enable port forwarding so that a web browser window can be opened up back on your local machine.↩︎