This is a companion discussion topic for the original entry at https://blog.rstudio.com/2021/10/21/embedding-shiny-apps-in-tableau-dashboards-using-shinytableau
At RStudio, we strive to help you combine the power of code-first data science with the other tools in your toolkit. Many organizations rely on Tableau for creating data dashboards, but there may be moments where you wish you could take advantage of R’s powerful reporting and visualization capabilities as well.
With the experimental shinytableau package, you can use the power of R and Shiny to customize objects that you embed in your Tableau dashboards. This package opens up the possibility to include interactive features beyond Tableau’s native capabilities, allowing you to be more flexible in meeting your organization’s data needs.
Is that a ggplot2 visualization in Tableau? With shinytableau, you can sit Tableau’s visualizations side-by-side with anything you can create in a Shiny application, including custom charts created with ggplot2. Since the Shiny app is embedded in Tableau, users of the dashboard won’t need to learn R or even realize they’re using a different tool.
Say you want to interactively use your extension with Tableau, such as pulling data from a worksheet to populate your chart. You can use Shiny to create a friendly user interface for specifying settings for your extension. With the right configuration, your Shiny app and Tableau can interact so that you can tell a cohesive story in your Tableau dashboard.
You can deploy shinytableau extensions like any other Shiny app, which allows you to use them in production. RStudio offers RStudio Connect and shinyapps.io as options to publish and host your Shiny apps. Read more on the Deployment and Hosting page of the shinytableau documents.
The authors of the shinytableau package, Joe Cheng, Richard Iannone, and Javier Luraschi, wrote a great tutorial on getting started with shinytableau. We highly recommend going through the tutorial to get a full understanding of the components of shinytableau, how they work together, and why each step is needed.
Here, we’ll break down the main steps of creating the authors’
ggviolin extension and how to embed it in Tableau’s Superstore sample workbook. Note that the violin plot in the videos has an applied palette and theme while the violin plot in the tutorial does not. Like any ggplot2 visualization, you can customize the plot to look how you would like!
Let’s begin in your RStudio console.
1. Start a new RStudio project
2. Install packages
Install your required packages. In addition to the packages you need for your Shiny app, you will also need remotes and shinytableau.
3. Edit the
Once shinytableau is installed, run the code below to open the
manifest.yml file. Edit the metadata to fit your extension. See an example in the shinytableau Github repository.
4. Create the shinytableau extension Shiny app
The next step is to create the extension. In addition to creating a Shiny app, you also need to configure the app so that it can interact with Tableau. This is the most technical part of the whole workflow and the tutorial details how to do this thoughtfully and in detail.
You can use the
ggviolin app code in the shinytableau Github repository as an example. Save this file as
app.R in your project.
5. Run the app and download the
app.R file and a dialogue box will appear. Click “Download” to download a
.trex file, which is what Tableau will use to create the extension.
Now, let’s move to Tableau. Be sure to leave your Shiny app running in RStudio! Otherwise, the connection will be lost and Tableau will not be able to open the extension.
6. Open the Superstore sample workbook in Tableau
The Superstore workbook should be available under Sample Workbooks:
If you want to create the same violin plots as you see in the images in this post, go to the “Performance” workbook. Under “Measure Names”, you can find “Profit Ratio”. Drag “Profit Ratio” under “Marks”.
7. Create the dashboard and load .trex file
Go to “Dashboard” then “New Dashboard”. In the new dashboard, drag the “Performance” workbook to where it says “Drop Sheets Here”, and then drag the “Extension” object to the dashboard. The “Add an Extension” box will automatically open.
Click “Access Local Extensions”, which will open a window. Navigate to and open your .trex file. Tableau will ask if you agree to open the extension. Click “OK” and your extension will appear in the dashboard.
8. Configure the extension
The Shiny app is in Tableau, but it doesn’t know what data to use. The next step is configuring the extension so that it uses the “Performance” worksheet data to render the violin plot.
Click the triangle button of the extension object, then go to “Configure”. This will open a dialogue box created in the Shiny app.
Fill out the form. Give it a title, choose the “Performance” worksheet, and select “Category” as the dimension and “AGG(Profit Ratio)” as the measure.
When you click “OK”, you will see the violin plot populate in the extension object. Congratulations! With the shinytableau package, you created a Tableau dashboard extension using R and Shiny.
Using the power of R and Shiny, you can combine the powers of your available tools to create insightful dashboards. shinytableau is still experimental and we would love your feedback on what you hope to see from the package.
We recommend reviewing the tutorial for shinytableau to learn more about how to customize it to your needs.
Looking for other ways of leveraging the power of R and Python with Tableau? Last week, we announced support for Tableau Analytics Extensions on RStudio Connect, which allows you to create calculated fields in workbooks that can execute R and Python scripts outside of the Tableau environment.
Learn more about leveraging business intelligence tools like Tableau alongside open source data science at our RStudio Community Enterprise Meetup on Leveraging R & Python in Tableau with RStudio Connect on Friday, October 29, 2021.