6 Replies Latest reply on Sep 4, 2018 9:28 AM by Hanane Ouhammouch

    R and tableau Online

    Hanane Ouhammouch

      Hi all

       

      I have question plz,

       

      Do R need any configuration  on Tableau online?

       

      If yes what is the step?

       

      If no how can i define a function and use it in the workbook ?

       

      In my case i define a function : list_brand()   whitch is used in a calculation field

       

       

      Thank you for your help

        • 1. Re: R and tableau Online
          suman kumar

          Hi,

           

          here I have attached link for info. Please go through it.

           

          Tableau’s R Integration | Association Analytics

          Step 1. Set Up R on Your Computer

          First, you will need to have a user interface for R on your computer. We recommend R Studio Desktop.

          Step 2. Install RServe Package

          Next, you will need to install the RServe package. To do this, click on Packages -> Install. Then, type in RServe and it will find the package for you to install.
          reserve

          Step 3. Set Up Rserve Connection

          Now you will need to run the following code to start up the Rserve connection:
          library(Rserve)
          Rserve()

          Step 4. Set Up the External Connection in Tableau

          There is one more thing you will need to do prior to writing in R in Tableau, but to do this you will need to switch over to Tableau. Tableau needs to have the external connection set-up in order to run R.  Go to the Help -> Settings and Performance -> Manage External Connections.
          R Serve

          In the pop-up, type in localhost for the Server name. Click on Test Connection to verify it is now connected.

          Step 5. Start Using R Integration

          At this point, we can now start taking advantage of the R integration.  The integration uses calculated fields to pass R code. There are four different types of calculations used in the R integration:

          1. SCRIPT_BOOL
          2. SCRIPT_INT
          3. SCRIPT_REAL
          4. SCRIPT_STR

          Which one you use depends on what type of value you expect to get as a result of your R Code.  SCRIPT_BOOL would be used if you expected a TRUE/FALSE value returned.  SCRIPT_INT would be used if you expected to have an integer returned.  SCRIPT_REAL would be used if you expected a numeric value returned.  SCRIPT_STR would be used if you expected a string value to be returned.
          The basic set-up of any R calculated field is as follows:
          SCRIPT_REAL (
          “R code”,
          Tableau fields being passed in
          )
          The R code would be encased by quote marks and the parenthesis would encase both the R code and any Tableau measures/dimensions that will be used inside the R code. You can pass in multiple Tableau fields, you will just need to separate the field names using a comma.
          Two important items to know is that inside the R code, you do not use the Tableau field name. You will use .arg and you cannot mix aggregate and non-aggregate arguments.  Here is an example below.
          script_bool
          Within my R code, I would need to refer to sum([Profit]) as .arg1 and ATTR([Department]) as .arg2.  Also, I made Department an Attribute in order to use both it and Profit.

          Example of R and Tableau in Action

          Now that you have the basics of the calculated field, here’s a real life example using the Superstore dataset. We’ll be looking at the correlation between Profit and Discount.  The returned value will be a numeric value, so I will be using SCRIPT_REAL.
          script_real

          Please mark correct and Helpful if it works for you.

           

          Best

          Suman

          1 of 1 people found this helpful
          • 2. Re: R and tableau Online
            Hanane Ouhammouch

            Thanks

             

            but i is not working in tableau online

             

            R and tableau Online

            • 3. Re: R and tableau Online
              suman kumar

              You need to integrate Tableau Desktop with R and then write your calculation in Calculated field which you can use in Tableau desktop to create report. Then publish it on Tableau Online. You can't do it in Tableau Online.

              • 4. Re: R and tableau Online
                Hanane Ouhammouch

                Yes i understand but.

                 

                how my workbook can be able to connect to R from tableau online?

                • 5. Re: R and tableau Online
                  suman kumar

                  Hi Hanane Ouhammouch

                   

                  You need to download your workbook from Tableau Online and then connect R.

                  Once it will be connected then you can publish it again on Tableau Online.

                   

                   

                  Best

                  Suman

                  1 of 1 people found this helpful
                  • 6. Re: R and tableau Online
                    Hanane Ouhammouch

                    in this case tableau online gonna be connected to my Local (R) .

                     

                    i will test it and let you know .

                     

                    Thank you for your help