Using R functions
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 within the functions panel those entries beginning with SCRIPT_
, as shown in the following image:
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 T|F values, and so on.
The syntax of a SCRIPT
function is represented in the following diagram:
Exercise - reproducing native Tableau functionality in R
For our first example, we will use the AVG
, MEDIAN
, and STDEV
functions in Tableau and compare the results with the mean, median, and sd R functions. This will allow you to practice the SCRIPT
functions, begin to understand R syntax, and compare results generated by Tableau with those generated by R:
- Navigate to https://public.tableau.com/profile/david.baldwin#!/ to locate and download...