user3692056
user3692056

Reputation: 51

Tableau Correlation using R

I am currently trying to do a Spearman's Rank Correlation in Tableau using the new R capability. I was able to get the correct code in R, but having trouble putting it in a form for Tableau to understand.

My data is grouped by code. So it is a Group Correlation. My code in R:

library (plyr)
ddply(mydata,"Code",summarise, corr=cor(Survey.1,Survey.2, method="spearman"))

How do I use the Script_Real in Tableau to give me that correlation?

Upvotes: 2

Views: 2375

Answers (2)

user3692056
user3692056

Reputation: 51

For those wanting to understand the coding. I have figured it out!

Script_Real("cor(.arg1,.arg2, method='spearman')",SUM([x]), Sum([y])).

Note: You need to have ID:1,2,3,4,5,6,7 near your data in order for it to run the test. Then click the pill and compute using that ID code.

Upvotes: 3

Alex Blakemore
Alex Blakemore

Reputation: 11896

One step you need is to configure the connection to R. See the help menu ->Settings and Performance > Manage R Connection

If you are using Tableau server, that will need to know the connection path to RServe as well. See the online help.

Upvotes: 1

Related Questions