Tableau vs. R Shiny: Which Excel Alternative Is Right For You?

[This article was first published on r – Appsilon Data Science | End­ to­ End Data Science Solutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

tl;dr

As of late 2020 there are many dashboarding/reporting/BI tools out there, with the most popular ones being TableauPowerBI, and R Shiny. The question quickly becomes – “How can I determine the right tool for my particular needs?” Today we’ll compare two of the most widely used tools at Fortune 500 companies:

  • Tableau – an intuitive and straightforward drag and drop solution used for data analysis 
  • R Shiny – a web framework written in R, widely used to make dashboards and interactive web applications

A comparison between Tableau, R Shiny, and PowerBI is a topic for another day, so stay tuned to our blog for more.

Let’s get one thing out of the way – R Shiny is not a reporting/dashboarding tool. Most people use it to make dashboards, so we can consider this comparison fair. As mentioned earlier, R Shiny is a full web framework. With it comes some obvious benefits and some considerations you need to have in mind when comparing it to tools like TableauWe’ll examine the following areas where Tableau and R Shiny compete with one another and declare a winner (or tie) for each:

At Appsilon we are global leaders in R Shiny and we’ve developed some of the world’s most advanced R Shiny dashboards, so we have a natural bias towards using Shiny. However, many members of our team have experience with using Tableau in professional settings, and we will do our best to be impartial in this article to help you decide whether Tableau or R shiny is truly best for your particular needs.

Connectivity

Tableau comes with two options with regards to connecting to data. First, you can connect to a local file – such as CSVExcelJSONPDFSpatial, etc. Alternatively, you can connect to a remote server. The options there are far too many to list, so here’s a screenshot of the current offerings (late 2020):

Tableau server connections

So yeah, there are a lot of options with Tableau. On the other side, R Shiny uses R as the programming language of choice, so Shiny can connect to any source that R can. Just like with its competitor, the options here are endless. A simple Google search will yield either a premade library or an example of API calls for any data source type. For domain-specific sources, R Shiny can sometimes have an edge. For instance, with R Shiny you can load and analyze gene expression data or CAD files. These kinds of sources can be problematic for Tableau. 

Winner (Connectivity): Tie, with an edge for R Shiny in domain-specific situations

Chart Types

Once again, Tableau doesn’t come up short here, with a plethora of visualization options such as bar charts, pie charts, line and area charts, and even more complex options such as geographical plots. Refer to the image below for the full list:

Tableau visualization options

Still, R Shiny demolishes the competition in terms of optionality for chart types. The most widely used visualization libraries are ggplot2 and Plotly. Here’s an overview of the types of visualizations you can make with ggplot2:

 

And here are some cool things that you can do with Plotly:

It’s a no brainer that R Shiny wins this battle in terms of chart options overall.

Winner (Chart Types): R Shiny

Ease of Use: Simple Charts

We’ll now see the extent of the trouble you’ll have to go through to create a simple bar chart, both in Tableau and R Shiny. For demonstration purposes, we’ll use the Titanic dataset, so download the CSV file linked here if you’re following along. To be more precise, we’ll create a bar chart containing passenger classes on the x-axis and average age on the y-axis.

Let’s start with Tableau. After the data imports, it’s relatively easy to create a visualization. Just follow the steps from the image below:

Tableau bar chart

That was very easy, as Tableau was designed to be intuitive and simple to use for non-technical people. This ease of use comes with a cost called customizability, but more on that later. 

Creating a simple chart is quite a different story with R Shiny. We need to write actual code to get a simple bar chart. First, we need to aggregate the Titanic dataset somehow, so we have the data in a concise, visualizable format. Next, we need to introduce some amount of boilerplate to manage the UI and the server. It’s only a couple of lines of code – negligible for larger projects, but a real obstacle for someone non-technical to create a simple chart.

Refer to the code below:

library(shiny)
library(ggplot2)

ui <- fluidPage(
    plotOutput('bar')
)

server <- function(input, output) {
    output$bar <- renderPlot({
        pclass_age_data <- titanic %>%
            select(Pclass, Age) %>%
            group_by(Pclass) %>%
            summarise(Age = round(mean(Age, na.rm=TRUE), 2))
        ggplot(data=pclass_age_data, aes(x=Pclass, y=Age)) +
            geom_bar(stat='identity', fill='steelblue') +
            geom_text(aes(label=Age), vjust=-0.3, size=5)
    })
}

shinyApp(ui=ui, server=server)

And here are the results:

Shiny simple bar

As you can see, there’s no point in using R Shiny if all you need are simple and straightforward data visualizations without any interactive elements. That’s where Tableau wins by a large margin. If you still want to use R for charts and you’re willing to put the effort in to have something fully customizable, then ggplot2 and Plotly are great options. However, even making simple charts with R can be an onerous task for non-technical people. We recommend Tableau for these kinds of tasks.

Winner (Simple Charts): Tableau

Ease of Use: Simple Dashboards

Alright, let’s see who will win in The Battle of the Dashboards. We won’t go too complex here, as dashboard development is a highly broad topic with many facets. Here’s an outline of the charts we’ll put into our dashboard:

  • Bar chart – average age per passenger class
  • Pie chart – genders
  • Histogram – ages

Also, all three charts should update when the user changes one of two filters:

  • Age slider – range slider from minimum to the maximum age of the passengers
  • Gender picker – option to exclude males or females from the visualizations

Here’s what the final dashboard looks like in Tableau:

This entire dashboard required 0 lines of code. We just needed a couple of minutes of clicking in the right places. The dashboard situation is different in R Shiny, as we need to write the actual R code there. However, it’s not too bad of a deal, since R is relatively easy to learn, and the customization possibilities are endless for Shiny dashboards.

The following code recreates the dashboard we had in Tableau:

library(shiny)
library(dplyr)
library(ggplot2)
library(titanic)
titanic <- titanic::titanic_train

ui <- fluidPage(
    sidebarPanel(
        width = 2,
        sliderInput(
            inputId='ageslider',
            label='Age range',
            min=min(titanic$Age, na.rm=T),
            max=max(titanic$Age, na.rm=T),
            value=c(min(titanic$Age, na.rm=T), max(titanic$Age, na.rm=T))
        ),
        selectInput(
            inputId='genderselect',
            label='Gender',
            choices=c('Male', 'Female'),
            selected=c('Male', 'Female'),
            multiple = TRUE
        )
    ),
    mainPanel(
        fluidRow(
            column(8, plotOutput('bar')),
            column(4, plotOutput('pie'))
        ),
        fluidRow(
            column(12, plotOutput('hist'))
        )
    )
)

server <- function(input, output) {
    output$bar <- renderPlot({
        pclass_age_data <- titanic %>%
            filter(Sex %in% tolower(input$genderselect)) %>%
            select(Pclass, Age) %>%
            filter(Age >= input$ageslider) %>%
            filter(Age <= input$ageslider) %>%
            group_by(Pclass) %>%
            summarise(Age = round(mean(Age, na.rm=TRUE), 2))
        ggplot(data=pclass_age_data, aes(x=Pclass, y=Age)) +
            geom_bar(stat='identity', fill='#4179ab') +
            geom_text(aes(label=Age), vjust=-0.3, size=5) +
            ggtitle('Avg. age per passenger class') +
            theme_void() +
            theme(plot.title=element_text(size=20), panel.background=element_blank())
    })
    output$pie <- renderPlot({
        pie_data <- titanic %>%
            filter(Sex %in% tolower(input$genderselect)) %>%
            filter(Age >= input$ageslider) %>%
            filter(Age <= input$ageslider) %>%
            select(Sex) %>%
            group_by(Sex) %>%
            count() %>%
            mutate(Midpoint = cumsum(n) - n / 2)
        ggplot(pie_data, aes(x='', y=n, fill=Sex)) +
            geom_bar(width=1, stat='identity', color='white') +
            coord_polar('y', start=0) +
            scale_fill_manual(values=c('#f34a53', '#4179ab')) +
            ggtitle('Gender pie chart') +
            theme_void() +
            theme(plot.title=element_text(size=20))
    })
    output$hist <- renderPlot({
        hist_data <- titanic %>%
            filter(Age >= input$ageslider) %>%
            filter(Age <= input$ageslider) %>%
            filter(Sex %in% tolower(input$genderselect)) %>%
            select(Age)
            ggplot(hist_data, aes(x=Age)) +
            geom_histogram(bins=20, color='#62aca8', fill='#1e9a95') +
            ggtitle('Age histogram') +
            theme_void() +
            theme(plot.title=element_text(size=20))
    })
}

shinyApp(ui=ui, server=server)

And here’s what the final product looks like:

Shiny dashboard

As you can see, this dashboard is quite unfinished. That’s what we’ll discuss in the last section of the article. It’s hard to announce a clear winner here, but R Shiny’s dashboard feels more solid to work in. Tableau’s dashboard is way too sensitive to accidental clicks, and the dashboards look pretty similar in a stock-state. However, as we saw, you can make a simple dashboard much faster with Tableau than with R Shiny. For this reason, we’ll declare Tableau the winner for simple dashboards, but only for ease of use. As you’ll see, R Shiny is a much better choice if you intend to ratchet up the complexity and visual style of your dashboards.

Winner (Simple Dashboards): Tableau by a nose

User Input and Interactivity

Here’s where things get especially interesting in our Tableau vs. R Shiny comparison. There’s simply not much you can do with user input in Tableau – it’s very limited, as it wasn’t designed for such things. However, inputs are essential for a well-built and interactive dashboard as they provide a way to, well, interact with the app. Interactivity is where R Shiny seriously outshines Tableau. 

R Shiny provides a wide array of input options. Instead of listing them, it’s better to show some of them:

Shiny inputs

Yeah, that’s a lot, and you can certainly do any task with them. One question that might immediately pop into your head as a business user: why is interactivity so important? 

Well, interactivity makes any dataset much easier to analyze. For example, the file input component can enable you to upload your own file to explore within the dashboard, which is then further filtered by date (date range input) and column selectors (var select). This is contrasted with read-only dashboards that don’t allow the user to upload or interact with the data.

With R Shiny dashboards, you can also build complete interactive forms with password and text field input capabilities. That adds another critical layer of optionality for Shiny end users. Interactivity is a large part of what separates simple dashboards from powerful, enterprise-level business tools.

Winner (User Input): R Shiny

Visual Styling

Unfortunately, there isn’t much you can do to tweak the visuals in Tableau. It’s designed to look good out-of-the-box, and it’s up to you to change the colors, axes, titles, fonts, and other minor things. The amount of tweakable aspects depends on the type of plot you’re tweaking, but in general, Tableau doesn’t give you as much control as Shiny does. 

Here’s an example of how to change the colors of a histogram:

Tableau tweaking

R Shiny is a whole other animal. You can customize everything. To start, create a folder www right where your app.R is located. Inside it, create a main.css file. Yes, you’ve got it right – we can use everything CSS has to offer when it comes to styling R Shiny dashboards.

Learn More: How to Use CSS to Style Your R Shiny Dashboards

To connect the Shiny app to a CSS file, we can put theme=main.css right after the fluidPage in the R file. That’s all. It’s really that simple. Here’s what we managed to do in a couple of minutes with CSS and R Shiny:

Final Shiny dashboard

Here’s the source code for the final styled Shiny dashboard. Give this CSS optionality to a qualified designer, and you can achieve pretty much anything with R Shiny when it comes to visuals. One of our engineers even created an entire functional card-swiping video game in R Shiny by taking advantage of custom CSS styling (and some JavaScript magic).

Shiny Decisions is a video game made in R Shiny by Appsilon engineer Pedro Silva.

 The winner for the visual styling section is once again pretty obvious. R Shiny blows Tableau out of the water when it comes to visual customization, even if Tableau dashboards look fairly decent out of the box.

Winner (Visual Styling): R Shiny

Looking for some attractive Shiny dashboard examples? Find inspiration here in our demo gallery.

Conclusion

Here are the final results, according to our calculations:

  • R Shiny – 3 points
  • Tableau – 2 points
  • Tie – 1 point

So, is Shiny is a clear winner for all situations? Well, no. It depends on the type of work you need to do. If you need to sketch a single chart or graph quickly, or need to make a dead-simple dashboard every now and then, Shiny may be overkill. Tableau was designed for exactly these sorts of tasks. Further, if you’re a non-technical person and you don’t want to dig too much into the actual code, then Tableau is a great choice for simple charts and dashboards. 

Learn More: Why You Should Use R Shiny for Enterprise Application Development

Also, keep in mind that Tableau isn’t free. Tableau licenses go up from a baseline of $70 per month when billed annually, so it’s not an inexpensive piece of software. This isn’t an issue for Fortune 500 companies, but if you are an individual trying to decide on the right tool, Tableau’s price might be a dealbreaker. Alternatively, R Shiny is an open-source solution and is completely free to use (though if you need to host your Shiny app online, you might want to invest in an RStudio Connect license).

If you need to create powerful, customizable, and interactive dashboards that look great and respond to user input, then Shiny is a clear choice. Shiny requires a bit of coding knowledge even for simple dashboards, sure, but R isn’t a very complicated language. Most people find R much easier to learn than you might think. You can quickly get up to speed in a couple of weeks or even a couple of days, depending on your prior knowledge of programming. If you want to make a scalable enterprise Shiny dashboard, then you can always reach out to Appsilon for help. We’re constantly pushing the limits of what’s possible with Shiny, and we’d be happy to provide guidance for you and your company. 

Learn More

Article Tableau vs. R Shiny: Which Excel Alternative Is Right For You? comes from Appsilon Data Science | End­ to­ End Data Science Solutions.

To leave a comment for the author, please follow the link and comment on their blog: r – Appsilon Data Science | End­ to­ End Data Science Solutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)