attheoaks.com

Publishing Your Shiny App: A Comprehensive Guide to shinyapps.io

Written on

Introduction to Publishing Shiny Apps

The surge of interactive applications and dashboards during the COVID-19 pandemic has inspired many creators. Recently, a reader inquired about the process of publishing her newly developed Shiny app. Drawing from a previous article that detailed how to upload R code to GitHub, I decided it would be beneficial to share the steps I follow to publish my Shiny apps.

Before diving into the deployment process, you can preview my Shiny apps here.

Note: The screenshots provided in this guide were captured on MacOS. If you are using Windows, please share your experience in the comments.

Note: While there are various methods for publishing apps (such as using Docker), the approach outlined here is straightforward and effective.

Prerequisites for Deployment

To follow this guide, you will need to create an account on the shinyapps.io platform, which I personally utilize for deploying my Shiny applications. They offer a free tier that supports up to five active applications with a limit of 25 active hours per month. If you anticipate a wider audience for your app, be prepared to exceed this monthly cap quickly. To accommodate more than five apps or to increase the active hours, you will need to opt for a paid plan.

Step-by-Step Publishing Process

Here are the steps to publish your Shiny app, illustrated with images.

Step 1: Launch RStudio and initiate a new Shiny app:

Creating a new Shiny app in RStudio

Step 2: Assign a name (without spaces), select a save location, and click the Create button:

Naming and saving the new Shiny app

Step 3: Similar to creating a new R Markdown document, a basic Shiny app code will be generated. Click the Run App button to see it in action:

Running the basic Shiny app

Step 4: Once the basic app is open, it’s time to publish:

Publishing the Shiny app

Step 5: If this is your first app, the "Publish From Account" section will be empty. Click "Add New Account" to connect your shinyapps.io account:

Adding a new account for publishing

Step 6: Select the first option (ShinyApps.io):

Selecting ShinyApps.io for account linking

Step 7: Click on the link to access your ShinyApps account:

Accessing your ShinyApps account

Step 8: Click the Dashboard button to log into your account:

Logging into the ShinyApps dashboard

Step 9: Click on your name, then on Tokens:

Accessing tokens in your ShinyApps account

Step 10: If you haven't created any tokens yet, click on "Add Token." Then press the Show button:

Creating a new token for your account

Step 11: Click the Show Secret button:

Revealing your secret token

Step 12: The code will now be fully visible. Click the Copy to clipboard button:

Copying the token code

Step 13: Paste the code into the console in RStudio and execute it:

Pasting the code into RStudio

Your system is now authorized to deploy apps to your shinyapps.io account.

Step 14: Return to the publishing window, assign a title (without spaces), and click the Publish button:

Finalizing the app title before publishing

Step 15: After a few moments (depending on your app's size), your Shiny app should open in your web browser:

Viewing the published Shiny app in the browser

Step 16: You can now edit your app or replace its entire code. To illustrate this, I added a link for more information in the side panel:

Editing the app with additional information

Step 17: Verify that your changes are reflected (the link should appear in the side panel) and republish the app:

Checking modifications before republishing

Step 18: Click the Publish button again:

Finalizing the republish of your app

Step 19: Congratulations! Your app is now live, and you can share the link with others:

Sharing your live Shiny app with users

Additional Notes on App Settings

To modify your Shiny app settings, navigate to your shinyapps.io dashboard and select the app you just published:

Accessing app settings in shinyapps.io

Explore the various settings available in the tabs at the top of the window, and find the link to your app next to the URL field:

Overview of app settings and URL

Publishing Your Dataset

If your Shiny app relies on a dataset not loaded by default in R (for instance, one saved locally), you will need to publish that data alongside your app (ensure to check the box for your dataset):

Publishing your dataset with the Shiny app

Alternatively, for greater flexibility, you can host your dataset online. If you own a website, you can publish it there. If not, consider using GitHub to host your dataset (if you don't have an account, now is a great time to create one!). Finally, import the data into your app using the new URL.

Thank you for reading this guide. I hope it assists you in publishing your first Shiny app. As always, feel free to leave any questions or suggestions in the comments to benefit other readers.

Video Resources

To enhance your understanding of deploying Shiny apps, check out these video tutorials:

  1. How to Deploy R Shiny App for Free on Shinyapps.io

    This video provides a comprehensive walkthrough on deploying your Shiny app for free using shinyapps.io.

  2. Publishing apps to shinyapps.io

    This tutorial explains the steps necessary to publish your applications effectively on shinyapps.io.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Xi's Divide and Conquer Strategy: Lessons from Ancient Greece

Analyzing Xi's tactics in Europe through the lens of ancient Greek history.

Navigating the Divide: Alternative vs. Conventional Medicine

A deep dive into the effectiveness of alternative and conventional medicine, highlighting their unique benefits and potential drawbacks.

Unlocking Leadership: 7 Principles for Effective Leadership

Discover seven key principles of leadership that can transform your ability to lead and inspire others in the workplace.

Essential Running Drills for Enhanced Speed and Strength

Discover key running drills to boost your speed and strength, suitable for all fitness levels.

Innovative Side Hustle Strategies for Developers in 2024

Discover 7 lucrative side hustle ideas for developers in 2024, complete with insights and practical advice for success.

Exploring Genetic Influences on Monogamy and Commitment

Investigating the role of genetics in monogamous behavior and its evolutionary implications.

A Playful Take on Logical Reasoning Through Science

Explore the term 'scientifical' and its humorous take on scientific reasoning while fostering open discussions.

Unlocking Pain-Free Pushups: A Guide to Stronger Wrists

Discover effective techniques to strengthen your wrists for pain-free pushups, perfect for anyone recovering from wrist issues.