Tableau and R: FAQ
This document answers 10 frequently asked questions about Tableau’s integration with R. For questions about getting started, how to set up R integration and the Rserve package with Tableau Desktop and Tableau Server, please see this whitepaper and this Knowledge Base article.
You can also find additional resources, included a recorded webinar on the R Solutions page.
- Can we use precompiled packages, models, and other things with Tableau and R?
- When integrating Tableau and R, what is the best practice for debugging R scripts or discovering errors?
- Can you use R to reshape data?
- Can Tableau pass data from a relational database to R?
- Can you dynamically pass various levels of drill-down dimensions to an R function?
- How do you run a function with a mix of variable types?
- Can you insert R images and graphics into Tableau?
- What is the best practice for R Integration with Tableau that R models can be reused within the same session?
- Does Tableau Reader integrate with R?
- Are there future plans for deeper integration with R?
1.
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.
2.
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.
3.
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.
4.
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.
5.
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.