1 Reply Latest reply on Dec 14, 2017 11:31 AM by Yuriy Fal

    R & Tableau - Output error

    Lawrence Chan

      I am trying to integrate Tableau and R by having it display the results of the R output function. The Tableau function I am using is: SCRIPT_STR("rep(.arg1, 10)", ATTR([F1]))

      The error message I get is 'Unexpected number of results returned by SCRIPT function. Function expected 1 values; 10 values were returned.'. Attached is the Tableau workbook.


      I realize I am inputting a vector of length that is not equal to the number of rows in the Tableau result table (https://onlinehelp.tableau.com/current/pro/desktop/en-us/r_connection_troubleshoot.html#any). Has anyone figured out any "tricks" to output results without the error above? The output would be in the format of a dataframe where each value is a row in Tableau. For this example, the desired output would be:


      Desired output:

      Row 1: Test1

      Row 2: Test1

      Row 3: Test1


      Row 10: Test1



      Ideally, I would like to be able to do this for different R-functions that outputs a dataframe of various sizes in Tableau.

        • 1. Re: R & Tableau - Output error
          Yuriy Fal

          Hi Lawrence,


          To be able to get the result vector a different size

          a view should be built in a special way -- having

          the same number of Marks as the result vector(s)'.


          It means some kind of data densification to happen.

          In your particular sample case, the three-row dataset

          should be densified to get the thirty-mark view.


          There are ways to do data densification,

          i've used a simple one -- joining your table

          with the two-rows-by-one-column 'scaffold' table,

          then binning with the Parameter.


          Joining requires a Join Calculation,

          hence version 10.2 workbook.

          If you're on a previous version,

          and not able to open it, please reply,

          i'll make a modified wb (version 10.0).


          Please find the attached.