4 Replies Latest reply on May 30, 2018 1:04 PM by Andrew Bickert

    R while loop in tableau

    Mackenzie Cesar

      I have intermediate experience working with R and Tableau and I need some help from someone who has experience integrating R into Tableau. Basically I need the output of a while loop using the last values of the arguments I listed,  and I'm not sure what I'm doing wrong in terms of my calculation. I've attached my calculation below and it works fine in R studio. The results of my calc thus far dont appear in the viz. I am using while loop instead of forecast package because I need to control the linear rate of growth for a short period

        • 1. Re: R while loop in tableau
          Andrew Bickert

          Hi Mackenzie,


          Are you able to attach your .twbx file to help troubleshoot?

           

          Also, what library are you using on this?

           

          Andrew

          • 2. Re: R while loop in tableau
            Mackenzie Cesar

            I cant release the workbook because of HIPPA but Im putting together a sample workbook now. Im not using any packages except for Rserve and Lubriadate

            • 3. Re: R while loop in tableau
              Mackenzie Cesar

              main error message Im getting:

              Unexpected number of results returned by SCRIPT function. Function expected 53 values; 63 values were returned.

              Unexpected number of results returned by SCRIPT function. Function expected 53 values; 63 values were returned.

               

              im still developing the code to make this work

              • 4. Re: R while loop in tableau
                Andrew Bickert

                Hi Mackenzie,

                 

                Yes if you can get the sample data that would be very helpful.

                 

                Predictive forecasting in R requires you to append additional rows onto your data in order for the extra values to be displayed. it looks like you have worked on that by using the append() argument.

                From the error above it looks like there might be something wrong with your d1<-append(.arg3,d1,after=v) which is related to the d=ymd(d) +month(1);

                 

                With lubridate, it also used to be that if the date add function was not valid it would return a n/a value by using the basic logic a + b - b = a (ie: add 1 month to January 31, 2018 it would be February 31, 2018 which is not a valid date).

                 

                Is the Application Received Date always on the 1st of the month in your base query or is it periodic in nature?

                 

                Andrew