0 votes
1 view
in BI by (13.4k points)
edited by

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? 

1 Answer

0 votes
by (36.7k points)
  • Implement this code below

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.