shinytableau.Rmd
The {shinytableau} package allows you to easily extend Tableau dashboards using the power of R and Shiny. In typical Shiny fashion, it’s not necessary to know web technologies like HTML, JavaScript, and CSS to create compelling Tableau extensions.
Tableau version 2020.3 introduced a new extensibility feature called Dashboard Extensions. This feature lets programmers use JavaScript to create custom objects that normal Tableau users can drop into their Tableau dashboard layouts, providing custom visualizations and interactive features beyond Tableau’s native capabilities. The shinytableau package is a bridge between the JavaScript-based Tableau Dashboard Extension API, and Shiny code that you as an R practitioner will write. The resulting app can be used easily by Tableau dashboard authors, who don’t need to know anything about R or Shiny.
Tableau doesn’t have built-in support for violin plots, only boxplots. While boxplots are more familiar, violin plots are more informative because they show you the entire distribution instead of merely quartiles. For example, take a look at the same data drawn as a boxplot (left) and a violin plot (right):
The boxplot doesn’t give any hint that these values follow a bimodal distribution, while the violin plot makes it clear.
I would be remiss not to mention the heroics that Tableau consultant Gwilym Lockwood went through to create a violin plot in Tableau. The blog post is worth a read, but the takeaway is that you’d have to really want a violin plot to go through all of those steps.
In R, on the other hand, there are several packages that provide violin plots; a cursory search turned up vioplot, plotly, ggpubr, and ggplot2. Here’s how you might create a violin plot in ggplot2, using the mtcars
data set, showing the horsepower (hp
) distribution for each cylinder count (cyl
):
ggplot(mtcars, aes(x = factor(cyl), y = hp)) +
geom_violin()
With shinytableau, we can wrap this R code into an easy-to-use Tableau dashboard extension that can be used by Tableau users that don’t even know what R is. They don’t need to modify the code to point to the data source and variables they want to plot, because you’re going to provide them with a GUI for that. They don’t need to think about how to configure R on their server, because you can deploy it just once for all users of the extension.
Take a look at what it’s like to use a shinytableau extension:
To recap:
You (and other Tableau users) can use the same shinytableau extension across multiple dashboards. And just as a single Tableau dashboard can contain multiple (e.g.) bar chart sheets, each with its own view of the data, you can also have one shinytableau extension appear multiple times in a dashboard, with each instance configured differently.
We’ll come back to violin plots later, but let’s look at some much simpler examples first.
Next step: Writing your first extension