Shiny Session 3

shiny

Third Shiny Training Session: App Deployment and Full Demo Application

Bryan Blanc https://github.com/bpb824
01-14-2021

This content was presented to Nelson\Nygaard Staff for the Shiny Webinar series on Wednesday, September 23rd, 2020, and is available as a recording here and is embedded below.

Today’s Agenda

Application Deployment

Up to this point, you have only run your Shiny apps locally in RStudio, but obviously one of the best parts about Shiny apps is sharing them with others! Shiny can be hosted on a private server computer, like a personal or company server, or – as is more common – can be hosted on a cloud computing service like Amazon Web Services (AWS). However, the easiest way we have found to host Shiny apps is through a service provided by RStudio – shinyapps.io – that enables applications to be bundled and uploaded directly through the RStudio desktop software. RStudio offers some nice features that you wouldn’t get out of the box on a private server, like a performance dashboard, a log history, user authentication, load balancing, and others (some I am sure I am not aware of). Nelson\Nygaard has a paid account with shinyapps.io that lets us upload basically as many applications as we want that we can set up as public or private (i.e. with authentication). There will be an upper limit on the number of applications we can deploy when we hit 2,080 active hours per month, but as of this writing we are averaging under 90 active hours per month – less than 5% of our capacity – so there is basically no marginal cost to the addition of new applications at this point. If we get to the point of meeting this threshold, we can upgrade our server to handle more active hours per month – this will mean we’re using Shiny to serve a lot of clients!

For now, all you will need to know is how to deploy applications to NN’s Shiny server. There is an admin dashboard we’re limiting access to for now to a small group, but will give deployment access to all those in this course using a private token. I will share the private token with folks in the private Slack channel for the Shiny course module. This token must not be shared outside this group, and should live in the private Slack channel for now. It is likely we will create a private Slack channel for users going forward where this can be stored. There is the potential to create multiple tokens, which is something we may explore in the future.

Bryan will now share his screen to walk through a sample deployment of the application we will be focusing on today. If you are viewing this after the fact, the sample application Bryan will be deploying is stored in the GitHub repository at this subfolder.

Example Application

This is an application I built in a few hours this morning to demonstrate some of the more complex capabilities that I think people will want to use in their applications. The example application is deployed on shinyapps.io here. To have a bit of fun with the example and still cover the capabilities I wanted to show, I decided to scrape the beverage (mostly beer) inventory that Belmont Station (a local bottle shop in Portland, OR) updates on their website each day. That means if you are looking at it on different days, the results will look slightly different (based on their live inventory). I will walk through the entire application itself, but will try to highlight some key pieces below.

Training App Screenshot

User Feedback

For many Shiny applications, you will want to be able to broadcast information to the user about what is going on behind the scenes. In this application, I used a couple different items to broadcast feedback to the user:

Map Interactivity

I talked in an earlier session about the use of maps for selection. This can get a bit complicated, but it is hopefully well demonstrated in this application. In general, I would review the relevant documentation before trying to do this in your application. Items to note from the application include:

Data Tables

I glossed over the use of DataTables in a previous session – they are great for presenting tabular data to the user in a user-friendly manner. They allow for sorting, searching, scrolling, paginating (though I don’t use that here), filtering, and have many other features including custom colors and fonts. Full documentation for the DataTable package is provided here.

This content was presented to Nelson\Nygaard Staff for the Shiny Webinar series on Wednesday, September 23rd, 2020, and is available as a recording here and is embedded at the top of the page.