4

I'm trying to use R and Tableau interactively, to run a model in R and visualize the results in Tableau.

My understanding is that the modeling data should be loaded in R.

I wrote this Calculated Field in Tableau to try to load data in R, however it keeps telling me that there's an unexpected return type. I don't know why it's trying to return any value yet.

SCRIPT_STR("
cat('     ',fill = T)
cat('*****************************************', fill = T)
cat('********** Loading Data in R ************', fill = T)
cat('*****************************************', fill = T)
cat(' ',fill = T)
path <- .arg1
print(path)
L1_stage_disposition <- readRDS(path)
", [Path to Data])

The parameter "Path to Data" in Tableau holds a valid reference to the desired RDS file. There is no error in Tableau until I add the line that says L1_stage_disposition <- readRDS(path).

If I use Rdata instead of RDS format data then I can see the data load in RStudio, however both give me the same error message about return types in Tableau.

Hack-R
  • 22,422
  • 14
  • 75
  • 131
  • What happens if you try that line (with the given path) manually in an interactive R session? – Philip Jan 11 '16 at 18:42
  • @Philip Good question, I should've mentioned that I did run it that way first successfully – Hack-R Jan 11 '16 at 18:50
  • The typical use case is that Tableau fetches the (aggregated) data from the external data source(s), organizes it according to the dimensions used in the view. Tableau then sends data to R, R performs calculations and returns results to Tableau for incorporation in the view. Try some of the simple examples of Using Tableau and R together first to see how they fit. – Alex Blakemore Jan 11 '16 at 22:14
  • @AlexBlakemore Oh, ok, I think I see what you're saying. I'm going to try it the way you're describing and update the post as soon as I can. What about model building though (still load the data in R first?). At the risk of overcomplicating this, I'm actually trying a Tableau + R + H2O-within-R use case of GLM. Anyway, thanks for the pointer I will try to follow up this morning or at least by later today. – Hack-R Jan 12 '16 at 14:38
  • If model building takes time, I think most people would build models in R initially without Tableau. Save the models (or coefficients or whatever needed to quickly reload the models). Then use the models by calling R from Tableau, where the first thing the script() call did was reload the models – Alex Blakemore Jan 16 '16 at 22:38

0 Answers0