Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Tableau 2021

You're reading from   Mastering Tableau 2021 Implement advanced business intelligence techniques and analytics with Tableau

Arrow left icon
Product type Paperback
Published in May 2021
Publisher Packt
ISBN-13 9781800561649
Length 792 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
David Baldwin David Baldwin
Author Profile Icon David Baldwin
David Baldwin
Marleen Meier Marleen Meier
Author Profile Icon Marleen Meier
Marleen Meier
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Getting Up to Speed – A Review of the Basics 2. All About Data – Getting Your Data Ready FREE CHAPTER 3. Tableau Prep Builder 4. All About Data – Joins, Blends, and Data Structures 5. Table Calculations 6. All About Data – Data Densification, Cubes, and Big Data 7. Level of Detail Calculations 8. Beyond the Basic Chart Types 9. Mapping 10. Tableau for Presentations 11. Visualization Best Practices and Dashboard Design 12. Advanced Analytics 13. Improving Performance 14. Interacting with Tableau Server/Online 15. Programming Tool Integration 16. Another Book You May Enjoy
17. Index

Implementing R functionality

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 15.7: 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 15.8: R script syntax

The preceding example code 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 hence prove that R is working properly.

Reproducing native Tableau functionality in R

For our first exercise, we will use the AVG, MEDIAN...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime