-
Book Overview & Buying
-
Table Of Contents
Mastering Tableau 2026 - Fifth Edition
By :
Now that we have successfully connected Tableau with R, let's write some code in Tableau to invoke R. Within Tableau, open the Calculated Field Editor. Notice the class of functions beginning with SCRIPT_, as shown in the following screenshot:

Figure 14.8: SCRIPT_ functions
The SCRIPT_ functions are used by Tableau to invoke R. The function names communicate the data type of the returned results; SCRIPT_REAL returns float values, SCRIPT_BOOL returns true or false values, and so forth.
The syntax of a SCRIPT_ function is represented in the following diagram:

Figure 14.9: R script syntax
The preceding example code Script_Real("mean(.arg1)",SUM(PROFIT)) calculates the average profit, but we will get to more examples in the next sections. Let's start by reproducing Tableau functionality using the R integration and validating that the R integration is functioning as expected.