Tableau and R Integration

23. July 2014 15:06 by Eric in Analytics, Tableau  //   Comments (0)

Hi All,

Have been tasked to put together a quick write-up about Tableau and R integration for the IM Dashboarding solution based upon the Tableau latest 8.2 releases.

Please see my research details as follows and more than welcome for any feedback from all of you:

As many people might know that Tableau just released the latest 8.2 version to the global market with a bunch of new exciting features (, do you also know that the Tableau also supports R Integration since version 8.1 on the Desktop & Server tools (Not on Tableau Reader yet).

Benefits for using R

As an open-source almost 2.5 million user base analytics platform, R provides a wide variety of analytic analysis goodies here – it includes that statistical tests, linear and nonlinear modeling, time-series analysis, classification and clustering.

There are many benefits by leveraging R into the Tableau toolkits and please see the key points as follows:

· It’s free and open-source backed by the community and millions professionals.

· The free functions and rich features can be created all the time by the domain experts and other industrial professionals and the quality of the libraries will be assured by the community and experts.

· Enrich Tableau with a growing collection of statistical analysis and data mining libraries to help them gain deeper insights from their data.

Integration with R

Getting R set up with Tableau Desktop/Server requires R and Rserve installed and configured.

· R can be simply grabbed from

· Rserve is a package created from Tableau communities in order to connect to the Tableau applications

· Rserve required to be installed on the command line and got connected to the Tableau via “Rserve Connection” configuration Screen or the tabadmin command line on the Tableau Server environment

· R functions and models can now be used in Tableau by creating new calculated fields that dynamically invoke the R engine and pass values to R.

Common Question about Tableau + R Integration

Q: Can we use precompiled packages, models, and other things with Tableau and R?

A: Yes. The general rule is, if you can do it in R, you can easily integrate it with Tableau. This includes any statistical packages, parallel computing packages, models and libraries, whether they are standard within R or if you create them independently. This also includes commercialized versions of R, including Revolution Analytics. You can also return data frames from R one column at a time.

Q: When integrating Tableau and R, what is the best practice for debugging R scripts or discovering errors?

A: There are two ways to do this. The first is to use the 'write.csv' command within the calculated field that calls an R script. The other, is to use the debug version of the standalone executable of Rserve (Rserve_d.exe) which will print out any code that R is performing as Tableau calls the R scripts.

Q: Can you use R to reshape data?

A: Yes, see this example ( where R and multidimensional scaling are used to reshape 1600+ columns into Tableau.

Q: Can Tableau pass data from a relational database to R?

A: Yes, Tableau can pass data from any source and run R scripts on that data, whether a flat-file, relational database, cube, or an unstructured data store.

Q: Can you dynamically pass various levels of drill-down dimensions to an R function?

A: Yes, and very easily too. In Tableau, R scripts are run in table calculations and therefore can be run against various dimensions. Simply change the aggregation level of the desired dimension and compute the table calculation accordingly.

Q: How do you run a function with a mix of variable types?

A: Tableau can send R mixed types of data. In SCRIPT_X, the X represents the variable type that is returned to Tableau. In most cases, the one column returned to Tableau will contain a single variable type. If there are mixed types (e.g. mixed number and text values), it can be returned as a string using SCRIPT_STR.

Q: What is the best practice for R Integration with Tableau that R models can be reused within the same session?

A: See this getting started whitepaper( about Rserve. It provides more details about saved sessions, and the difference between Windows and Linux installations of Rserve in private vs. shared environments.

Q: Does Tableau Reader integrate with R?

A : At this time, you will need Tableau Desktop or Tableau Server to view a Tableau workbook with R scripts.


Lastly, it’s also worth pointing out here that Tableau by default comes with its own built-in Analytics Models and capabilities, so please feel free to check out the following resources if you would like to explore:

Hope you would find it useful.

All Best,