I would like to know how to use table data as a parameter in Tableau's R integration.
Example
Tableau has a builtin data set called "Superstore" used for reproducible examples. Suppose I've used the Superstore data set to create a "text table" (i.e. spreadsheet) with Region
as rows and SUM(Profit)
as the data.
That looks like this:
Now, suppose I wanted to pass the data in this table to R for a calculation. I would start Rserve
library(Rserve)
Rserve()
and establish a connection with Tableau's UI.
Next I would want to create a calculated field to send the data to R and retrieve the results. I'm not sure how to do this.
My attempt looks like this:
SCRIPT_REAL('
output <- anRFunction(.arg1)
',
[someTableauMeasure])
which should be fine, except that I don't know how to represent the table data where it currently says someTableauMeasure
. This is just an arbitrary example, but a reason I might want to do this is that I might provide the user with a filter, such as Country
, so that they could filter the results at will and get an updated result from R.
For testing purposes that function anRFunction
could be replaced with something like abs
.