Search code examples
rtableau-apirserve

Print result in R console when passing variables to R script from Tableau to R


I am sending passing R scripts to R from Tableau and would like to be able to see the result in the R console. I have got this to work in the past, but not sure how to do it again.

In R I've ran the following lines of code: Note, [Petal Length] is just a column of number values- it doesn't matter what the numbers are. In this case I just got it from the IRIS dataset (which is pre-packaged in R as you can see if you run data())

install.packages("Rserve") 
library(Rserve)
run.Rserve() 

In Tableau, the calulated field that contains the R script is:

SCRIPT_INT('print(.arg1)', SUM([Petal length]))

Thanks.


Solution

  • After some searching I finally found the answer to this question. 1) you have to have the function print() in the Tableau calculated field, and 2) you have to use the command: run.Rserve() as opposed to Reserve().