0 Replies Latest reply on Oct 26, 2018 5:58 AM by Gio Ursu

    How to return multiple results from R

    Gio Ursu

      Hi all,

       

      I have encountered this challenge where I cannot pass multiple values back to R. Let me explain better. (Apologies in advance if my questions are silly, I am new to Tableau)

       

      Context: I have a number of categories (called "segments") (which are imported in Tableau as one dimension) and their respective quantities (transaction amounts) (in Tableau as a measure called "AvgmonthlyTrxn"). I am doing a pairwise comparison between the segments using the TukeyHSD method in R (following the anova test) and I want to pass the results of the Tukey test back to Tableau. Now I can pass back (from R into Tableau) one value (the p-value of the anova test for example), but I am having with the following:

       

      1) I cannot pass back the results from the Tukey calculations in R. The R result is a numerical value (a vector) with 3 elements. Please see the script below (result I am passing back into tableau is in step 6 as shown in the script):

      TableauAnovaScript.PNG

       

      Now, the strange thing is that if I create an identical vector (called "output" as shown in the script) with random values as in step 7, then the script works, but not when I pass back the result from step 6 (in which case I get an error saying something like THE OUTPUT PASSED INTO TABLEAU IS OF UNEXPECTED TYPE. I checked in R the types of both vectors and they are the same, so I am unsure why this happens and how to fix it. Could anyone please help me with that?
      TableauAnovaError.PNG

       

       

      2) The second is not a problem, but I think it's the reason behind my error above. I have checked various documentation, but I don't think I fully understand how tableau passes data to R and viceversa. Let's assume I have a column of numbers. How can I pass that into R so that I can use it as a vector in R? Could anyone explain that to me in very simple terms ( I have read the documentation already and it's not very clear to me) ? The reason I am saying this is because when I create a random vector as in step 7 (in the script) with less or more than 3 values, Tableau says that the expected result should contain 3 values. So my question is: why does it say that? and how does it determine that it should have 3 values in the result? It is very confusing.

       

       

       

      P.S. attached is the workbook if needed