# Tableau and R – Some Detailed Notes on What Goes to R and Back Again

Beyond all the statistical libraries, what  fascinates me about the Tableau & R integration is R’s ability to do iterative calculations on a given set of data, for example to compute Poisson confidence intervals. Since publishing the first post on funnel plots for proportions I’ve been gaining a better understanding of the interactions between R and Tableau while building the Poisson CI functions to support funnel plots for counts, rates, and indirectly standardized ratios. Since R is a new language for me, since the 8.1 beta besides learning syntax I’ve been trying to make sense of:

• How Tableau sends data to R
• What that data looks like when it gets to R (and how R can work with that)
• How R sends data back to Tableau (and how to set up the data so Tableau can work with it)

I kept a bunch of notes along the way, and I published them to the TabWiki on the Tableau Forums this weekend at:

Tableau and R Integration Wiki

If you’re using R and Tableau, I’m pretty sure this will be useful to you at some point, there’s a lot in there that hasn’t been documented yet. And this hasn’t been a solo project, I’ve gotten help along the way from Bora Beran, Andrew Ball, Mary in Tableau Support, and found the Tableau 8.1 Beta Forums quite useful as well. If you find out more, please contribute to the wiki!

# Comparing Each Against Each Other: The No-SQL Cross Product

Here’s a problem that has been bouncing around in my brain since I first used Tableau. How do I compare the results of every permutation of one item vs. another? Here’s an example using Superstore Sales – I put Region on Rows and Columns, and SUM(Sales) on the Text Shelf, and only see four values:

What if I want to compare Sales in Central to those in East, South, and West, and Sales in East to South and West, and Sales in West to Sales in South simultaneously? We can compare two at a time using parameters or a self-blend, or one vs. the rest in different ways via sets or table calcs or calculated fields, but how about each against each other? What if we want a correlation matrix? Read on to find out how to do this without any SQL, and learn a little bit about domain completion.

# General References

Statistics Done Wrong ebook
Learning Statistics with R psychology text

Basic statistics by Kelly Martin:
http://community.tableausoftware.com/docs/DOC-5269

# Process Control Charts

http://drawingwithnumbers.artisart.org/user-defined-functions-and-process-control-charts/

## Funnel Plots in Tableau

http://drawingwithnumbers.artisart.org/not-a-funnel-cake-nor-funnel-charts-its-funnel-plots/

# R

High-level Tableau Whitepaper http://www.tableausoftware.com/learn/whitepapers/using-r-and-tableau

Tableau’s R KB article
http://kb.tableausoftware.com/articles/knowledgebase/r-implementation-notes

Learning R
http://www.cookbook-r.com

Creating R packages
http://ricardianambivalence.com/2012/07/28/creating-an-r-package-in-10-mins/

SQL Equivalents in R Data Frames
http://vasaptexblog.wordpress.com/2014/01/29/r-simplified-playing-with-dataframes-1/

[loop category=”wikicontent” tag=”statistics,control-charts,spc,r,funnel-plots,stats”]
[field title] – Added [field date]
[content]
[/loop]

### Related posts:

[loop tag=”statistics,control-charts,spc,r,funnel-plots,stats” exclude=”this” relation=”and” compare=”not” taxonomy=”category” value=”wikicontent”]